gameServer2/src/utils.rs
changeset 13423 87a6cad20c90
parent 13416 cdf69667593b
child 13524 5359ff75da3a
--- a/gameServer2/src/utils.rs	Tue Jun 26 23:22:38 2018 +0300
+++ b/gameServer2/src/utils.rs	Wed Jun 27 02:34:46 2018 +0300
@@ -1,4 +1,6 @@
+use std::iter::Iterator;
 use mio;
+use base64::{encode};
 
 pub const PROTOCOL_VERSION : u32 = 3;
 pub const SERVER: mio::Token = mio::Token(1000000000 + 0);
@@ -9,4 +11,13 @@
         name.chars().any(|c|
             "$()*+?[]^{|}\x7F".contains(c) ||
                 '\x00' <= c && c <= '\x1F')
+}
+
+pub fn to_engine_msg<T>(msg: T) -> String
+    where T: Iterator<Item = u8> + Clone
+{
+    let mut tmp = Vec::new();
+    tmp.push(msg.clone().count() as u8);
+    tmp.extend(msg);
+    encode(&tmp)
 }
\ No newline at end of file