aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorZachary Dremann <dremann@gmail.com>2014-06-09 08:51:54 -0400
committerZachary Dremann <dremann@gmail.com>2014-06-09 08:51:54 -0400
commitb4643e1d1ec8f447d36f3794f3a051a64a090d16 (patch)
tree4eeb01e94dd417eb0372d1480f370a6a38497282 /examples
parent4098f06294a2a9c40f4183e9e2ce291550cb69fd (diff)
downloadrusty-irc-b4643e1d1ec8f447d36f3794f3a051a64a090d16.tar.gz
rusty-irc-b4643e1d1ec8f447d36f3794f3a051a64a090d16.zip
Using rust-empty for structure
Diffstat (limited to 'examples')
-rw-r--r--examples/hello.rs4
-rw-r--r--examples/main.rs25
2 files changed, 29 insertions, 0 deletions
diff --git a/examples/hello.rs b/examples/hello.rs
new file mode 100644
index 0000000..6f8dfa1
--- /dev/null
+++ b/examples/hello.rs
@@ -0,0 +1,4 @@
+fn main() {
+ println!("Hello!");
+}
+
diff --git a/examples/main.rs b/examples/main.rs
new file mode 100644
index 0000000..6ec9134
--- /dev/null
+++ b/examples/main.rs
@@ -0,0 +1,25 @@
+extern crate irc;
+
+use std::io::net::tcp::TcpStream;
+use std::io::BufferedReader;
+
+use irc::IrcConnection;
+use irc::msg::Message;
+use irc::msg::cmd;
+
+fn main() {
+ let message = Message {
+ prefix: None,
+ command: cmd::PrivMsg("#rust".to_string(), "Hi there everyone".to_string()),
+ };
+
+ println!("{}", message);
+
+ let on_msg = |message: &Message, _sender: &Sender<Message>| {
+ println!("{}", *message);
+ };
+
+ let mut connection = IrcConnection::connect("irc.mozilla.org", 6667, "Dr-Emann".to_string(), "dremann".to_string(), "Zachary Dremann".to_string(), on_msg).unwrap();
+
+ connection.run_loop();
+}