Exemplo n.º 1
0
        public static BasePacket Create(byte[] data, ChannelID channel)
        {
            switch (channel)
            {
            case ChannelID.Default:
                return(KeyCheckPacket.Create(data));

            case ChannelID.ClientToServer:
            case ChannelID.SynchClock:
            case ChannelID.Broadcast:
            case ChannelID.BroadcastUnreliable:
                return(GamePacket.Create(data));

            case ChannelID.Chat: {
                var packet = new Chat();
                packet.Read(data);
                return(packet);
            }

            case ChannelID.QuickChat: {
                var packet = new QuickChat();
                packet.Read(data);
                return(packet);
            }

            case ChannelID.LoadingScreen:
                return(LoadScreenPacket.Create(data));

            default:
                throw new IOException("Unknown packet channel.");
            }
        }
Exemplo n.º 2
0
        public BasePacket Create(PacketReader reader, ChannelID channel)
        {
            switch (channel)
            {
            case ChannelID.Default:
                return(KeyCheckPacket.Create(reader));

            case ChannelID.ClientToServer:
            case ChannelID.SynchClock:
            case ChannelID.Broadcast:
            case ChannelID.BroadcastUnreliable:
                return(GamePacket.Create(reader));

            case ChannelID.Chat:
                reader.ReadPad(0);
                return(Chat.CreateBody(reader));

            case ChannelID.QuickChat:
                reader.ReadPad(0);
                return(QuickChat.CreateBody(reader));

            case ChannelID.LoadingScreen:
                return(PayloadPacket.Create(reader));

            default:
                return(null);
            }
        }
Exemplo n.º 3
0
        public static QuickChat CreateBody(PacketReader reader)
        {
            var result = new QuickChat();

            result.ClientID  = reader.ReadClientID();
            result.MessageId = reader.ReadInt16();
            return(result);
        }