// Write msg to output stream public byte[] ToBytes() { MBinaryWriter mbw = new MBinaryWriter(); mbw.WriteString(protocol_version, protocol_version_size); mbw.Write(int_param); for (Int32 nElementIndex = 0; nElementIndex < int_array_size; ++nElementIndex) { mbw.Write(int_array[nElementIndex]); } mbw.WriteString(char_array, char_array_size); byte[] rand_string_field_bytes = rand_string_field.ToBytes(); mbw.Write(rand_string_field_bytes); for (Int32 nElementIndex = 0; nElementIndex < rand_string_array_size; ++nElementIndex) { byte[] rand_string_array_bytes = rand_string_array[nElementIndex].ToBytes(); mbw.Write(rand_string_array_bytes); } mbw.Write((Int16)enum_value); byte[] EchoMsg_bytes = mbw.ToArray(); mbw.Close(); mbw = null; // Verify the length of msg if (EchoMsg_bytes.Length != 270) { Console.WriteLine("Invalid msg len, expect:270, real:EchoMsg_bytes.Length"); return(null); } return(EchoMsg_bytes); }
// Write msg to output stream public byte[] ToBytes() { MBinaryWriter mbw = new MBinaryWriter(); mbw.WriteString(key, key_size); mbw.WriteString(value, value_size); byte[] KeyValuePair_bytes = mbw.ToArray(); mbw.Close(); mbw = null; // Verify the length of msg if (KeyValuePair_bytes.Length != 482) { Console.WriteLine("Invalid msg len, expect:482, real:KeyValuePair_bytes.Length"); return(null); } return(KeyValuePair_bytes); }
// Write msg to output stream public byte[] ToBytes() { MBinaryWriter mbw = new MBinaryWriter(); mbw.WriteString(data, data_size); byte[] RandString_bytes = mbw.ToArray(); mbw.Close(); mbw = null; // Verify the length of msg if (RandString_bytes.Length != 32) { Console.WriteLine("Invalid msg len, expect:32, real:RandString_bytes.Length"); return(null); } return(RandString_bytes); }
// Write msg to output stream public byte[] ToBytes() { MBinaryWriter mbw = new MBinaryWriter(); mbw.WriteString(content, content_size); mbw.Write(speaker_id); mbw.Write(time); byte[] ChatMsg_bytes = mbw.ToArray(); mbw.Close(); mbw = null; // Verify the length of msg if (ChatMsg_bytes.Length != 264) { Console.WriteLine("Invalid msg len, expect:264, real:ChatMsg_bytes.Length"); return(null); } return(ChatMsg_bytes); }