gameServer2/src/protocol/mod.rs
changeset 12132 1525923cd7e3
parent 12131 a4d22f197bd2
child 12133 81df2e1f9ae9
equal deleted inserted replaced
12131:a4d22f197bd2 12132:1525923cd7e3
     1 use netbuf;
     1 use netbuf;
     2 use std::io::Read;
     2 use std::io::Read;
     3 use std::io::Result;
     3 use std::io::Result;
     4 
     4 
     5 mod messages;
     5 mod messages;
     6 mod hwprotocol;
       
     7 mod lexer;
       
     8 
     6 
     9 pub struct FrameDecoder {
     7 pub struct FrameDecoder {
    10     buf: netbuf::Buf,
     8     buf: netbuf::Buf,
    11 }
     9 }
    12 
    10 
    23 
    21 
    24     pub fn extract_messages(&mut self) -> &[u8] {
    22     pub fn extract_messages(&mut self) -> &[u8] {
    25         &self.buf[..]
    23         &self.buf[..]
    26     }
    24     }
    27 }
    25 }
    28 
       
    29 #[test]
       
    30 fn testparser() {
       
    31     assert_eq!(messages::HWProtocolMessage::Nick("hey".to_string()),
       
    32                hwprotocol::parse_ProtocolMessage("NICK\nhey\n\n").unwrap());
       
    33 }