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."); } }
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); } }
public static QuickChat CreateBody(PacketReader reader) { var result = new QuickChat(); result.ClientID = reader.ReadClientID(); result.MessageId = reader.ReadInt16(); return(result); }