示例#1
0
        public void CreateAdminPacketService_ThatCanHandleAdminMessage()
        {
            IAdminMessage msg    = new AdminChatMessage(NetworkAction.NETWORK_ACTION_CHAT, ChatDestination.DESTTYPE_BROADCAST, 0, "MSG");
            Packet        packet = new AdminPacketServiceFactory().Create().CreatePacket(in msg);

            packet.PrepareToSend();
            Assert.Equal((byte)AdminMessageType.ADMIN_PACKET_ADMIN_CHAT, packet.ReadByte());
            Assert.Equal((byte)NetworkAction.NETWORK_ACTION_CHAT, packet.ReadByte());
            Assert.Equal((byte)ChatDestination.DESTTYPE_BROADCAST, packet.ReadByte());
            Assert.Equal(0u, packet.ReadU32());
            Assert.Equal("MSG", packet.ReadString());
        }
示例#2
0
        public static NetMessage SendSingleEntryToAdmins(AdminChatMessage chatMessage)
        {
            AdminChatUpdate update = new AdminChatUpdate();

            update.messages.Add(chatMessage);
            NetMessage msg =
                new NetMessage  {
                JsonData = JsonUtility.ToJson(update)
            };

            SendToAdmins(msg);
            return(msg);
        }
示例#3
0
    public static MentorPlayerChatUpdateMessage SendSingleEntryToMentors(AdminChatMessage chatMessage, string playerId)
    {
        AdminChatUpdate update = new AdminChatUpdate();

        update.messages.Add(chatMessage);
        MentorPlayerChatUpdateMessage msg =
            new MentorPlayerChatUpdateMessage  {
            JsonData = JsonUtility.ToJson(update), PlayerId = playerId
        };

        msg.SendToMentors();
        return(msg);
    }
        public void TransformMessageIntoPacket_WhenReceivedProperPacket()
        {
            AdminChatMessage msg = new AdminChatMessage(Game.NetworkAction.NETWORK_ACTION_CHAT,
                                                        Game.ChatDestination.DESTTYPE_BROADCAST,
                                                        destination: 5,
                                                        message: "Hello there");

            Packet packet = new AdminChatMessageTransformer().Transform(msg);

            packet.PrepareToSend();
            Assert.Equal(AdminMessageType.ADMIN_PACKET_ADMIN_CHAT, (AdminMessageType)packet.ReadByte());
            Assert.Equal(NetworkAction.NETWORK_ACTION_CHAT, (NetworkAction)packet.ReadByte());
            Assert.Equal(ChatDestination.DESTTYPE_BROADCAST, (ChatDestination)packet.ReadByte());
            Assert.Equal(5u, packet.ReadU32());
            Assert.Equal("Hello there", packet.ReadString());
        }