1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
pub mod connection;

mod command;
mod id;
mod line;
mod message;
mod pushmessage;
mod reply;
mod util;
mod word;

// rexport
pub use connection::Connection;

// structs
pub use id::Id;
pub use line::Line;
pub use message::Message;
pub use word::Word;

// enums
pub use command::Command;
pub use pushmessage::PushMessage;
pub use reply::Reply;

/*
#[cfg(test)]
mod tests {
    use tokio::net::*;
    use tokio::task;

    use super::command::Command;
    use super::connection::*;

    use futures::stream::StreamExt;

    #[test]
    fn it_works() {
        task::block_on(async {
            let (mut conn, mut push_channel) = Connection::connect(
                Type::Plain,
                SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 29536).into(),
            )
            .await
            .unwrap();

            let t = task::spawn(async move {
                loop {
                    let push_message = push_channel.next().await;
                    println!("{:?}", push_message);
                }
            });

            let res = conn
                .sendMessage(Command::Register("ham4", "kaas"))
                .await
                .unwrap();
            println!("{:?}", res);
            let res = conn
                .sendMessage(Command::Login("ham4", "kaas"))
                .await
                .unwrap();
            println!("{:?}", res);
            let room_id = conn.sendMessage(Command::CreateRoom).await.unwrap();
            println!("room {:?}", room_id);

            t.await;
        })
    }
}
*/