gameServer2/src/protocol.rs
changeset 12129 07972a8c2433
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gameServer2/src/protocol.rs	Tue Jan 03 00:19:47 2017 +0300
@@ -0,0 +1,24 @@
+use netbuf;
+use std::io::Read;
+use std::io::Result;
+
+
+pub struct FrameDecoder {
+    buf: netbuf::Buf,
+}
+
+impl FrameDecoder {
+    pub fn new() -> FrameDecoder {
+        FrameDecoder {
+            buf: netbuf::Buf::new()
+        }
+    }
+
+    pub fn read_from<R: Read>(&mut self, stream: &mut R) -> Result<usize> {
+        self.buf.read_from(stream)
+    }
+
+    pub fn extract_messages(&mut self) -> &[u8] {
+        &self.buf[..]
+    }
+}