Beispiel #1
0
        public void DeSerializeChatMessage()
        {
            const String testString = "test message";

            Chat chatMessage = new Chat(testString);

            var bytes = Utils.RawSerialize(chatMessage, Marshal.SizeOf(typeof(Chat)));

            var deserializedChatMessage = (Chat)Utils.RawDeSerialize(bytes, typeof(Chat));

            Assert.AreEqual(Packet.Type.Chat, (Packet.Type)deserializedChatMessage.PacketType);
            Assert.AreEqual(testString, deserializedChatMessage.Message);
        }
Beispiel #2
0
 // Broadcast packet to all connected clients.
 protected virtual void OnChatPacket(Object client, Chat chatPacket)
 {
     var broadCastData = Utils.RawSerialize(chatPacket);
     BroadCast(broadCastData);
 }