private RequestConvertor GetConvertor(PacketCmd cmd, Channel channelId) { var packetsHandledWhilePaused = new List <PacketCmd> { PacketCmd.PKT_UNPAUSE_GAME, PacketCmd.PKT_C2S_CHAR_LOADED, PacketCmd.PKT_C2S_CLICK, PacketCmd.PKT_C2S_CLIENT_READY, PacketCmd.PKT_C2S_EXIT, PacketCmd.PKT_C2S_HEART_BEAT, PacketCmd.PKT_C2S_QUERY_STATUS_REQ, PacketCmd.PKT_C2S_START_GAME, PacketCmd.PKT_C2S_WORLD_SEND_GAME_NUMBER, PacketCmd.PKT_CHAT_BOX_MESSAGE, PacketCmd.PKT_KEY_CHECK }; if (_game.IsPaused && !packetsHandledWhilePaused.Contains(cmd)) { return(null); } var key = new Tuple <PacketCmd, Channel>(cmd, channelId); if (_convertorTable.ContainsKey(key)) { return(_convertorTable[key]); } return(null); }
internal IPacketHandler GetHandler(PacketCmd cmd, Channel channelId) { var packetsHandledWhilePaused = new List <PacketCmd> { PacketCmd.PKT_UNPAUSE_GAME, PacketCmd.PKT_C2S_CHAR_LOADED, PacketCmd.PKT_C2S_CLICK, PacketCmd.PKT_C2S_CLIENT_READY, PacketCmd.PKT_C2S_EXIT, PacketCmd.PKT_C2S_HEART_BEAT, PacketCmd.PKT_C2S_QUERY_STATUS_REQ, PacketCmd.PKT_C2S_START_GAME, PacketCmd.PKT_C2S_WORLD_SEND_GAME_NUMBER, PacketCmd.PKT_CHAT_BOX_MESSAGE, PacketCmd.PKT_KEY_CHECK }; if (_game.IsPaused && !packetsHandledWhilePaused.Contains(cmd)) { return(null); } if (_handlerTable.ContainsKey(cmd)) { var handlers = _handlerTable[cmd]; if (handlers.ContainsKey(channelId)) { return(handlers[channelId]); } } return(null); }
public Packet(PacketCmd cmd = PacketCmd.PKT_KeyCheck) { memStream = new MemoryStream(); buffer = new BinaryWriter(memStream); buffer.Write((byte)cmd); }
/// <summary> /// Build a messagePart and call the ConstructMessage(); method. /// </summary> /// <param name="buffer">data received</param> /// <returns>Message of your protocol, builted</returns> public static Message BuildMessage(ENetClient client, Channel channel, byte[] buffer) { var reader = new LittleEndianReader(buffer); PacketCmd messageId = (PacketCmd)reader.ReadByte(); Message message; try { message = ConstructMessage(messageId, channel, reader); if (message == null) { logger.Write("Message: " + messageId + " not registered in protocol", MessageState.WARNING); } return(message); } catch (Exception ex) { logger.Write("Exception while building Message : (" + messageId + ") =>" + ex.Message, MessageState.WARNING); return(null); } finally { reader.Dispose(); } }
internal IPacketHandler GetHandler(PacketCmd cmd, Channel channelID) { var game = Program.ResolveDependency <Game>(); var packetsHandledWhilePaused = new List <PacketCmd> { PacketCmd.PKT_UnpauseGame, PacketCmd.PKT_C2S_CharLoaded, PacketCmd.PKT_C2S_Click, PacketCmd.PKT_C2S_ClientReady, PacketCmd.PKT_C2S_Exit, PacketCmd.PKT_C2S_HeartBeat, PacketCmd.PKT_C2S_QueryStatusReq, PacketCmd.PKT_C2S_StartGame, PacketCmd.PKT_C2S_World_SendGameNumber, PacketCmd.PKT_ChatBoxMessage, PacketCmd.PKT_KeyCheck }; if (game.IsPaused && !packetsHandledWhilePaused.Contains(cmd)) { return(null); } if (_handlerTable.ContainsKey(cmd)) { var handlers = _handlerTable[cmd]; if (handlers.ContainsKey(channelID)) { return(handlers[channelID]); } } return(null); }
public void SendDataPacket(PacketCmd cmd, int resend, byte[] buff, int offset, int len) { if (WriteDataAction != null) { byte[] packet = BuildDataPack(cmd, buff, offset, len); try { if (WriteDataAction != null) { WriteDataAction(packet, 0, packet.Length); } } catch { } TimeOutReload = TimeOut = deftimeout; ReSendCount = resend; RecvFlag = 1; tcmd = (int)cmd; if (resend != 0) { sendcmd = cmd; sendlen = packet.Length; } } }
public BuyItemRequest(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); cmd = (PacketCmd)reader.ReadByte(); netId = reader.ReadInt32(); id = reader.ReadInt32(); }
public uint targetNetId; // netId of the object used public UseObject(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); cmd = (PacketCmd)reader.ReadByte(); netId = reader.ReadInt32(); targetNetId = reader.ReadUInt32(); }
public SkillUpRequest(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); cmd = (PacketCmd)reader.ReadByte(); netId = reader.ReadUInt32(); skill = reader.ReadByte(); }
public SellItem(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); cmd = (PacketCmd)reader.ReadByte(); netId = reader.ReadInt32(); slotId = reader.ReadByte(); }
public SellItem(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { Cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadInt32(); SlotId = reader.ReadByte(); } }
public BuyItemRequest(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { _cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadInt32(); Id = reader.ReadInt32(); } }
public SwapItemsRequest(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); cmd = (PacketCmd)reader.ReadByte(); netId = reader.ReadInt32(); slotFrom = reader.ReadByte(); slotTo = reader.ReadByte(); }
public uint TargetNetId; // netId of the object used public UseObject(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { _cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadUInt32(); TargetNetId = reader.ReadUInt32(); } }
public SkillUpRequest(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { Cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadUInt32(); Skill = reader.ReadByte(); } }
public EmotionPacketRequest(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { Cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadUInt32(); Id = (EmotionType)reader.ReadByte(); } }
protected BasePacket(PacketCmd cmd, uint netId = 0) : base(cmd) { Write(netId); if ((short)cmd > 0xFF) // Make an extended packet instead { _bytes[0] = (byte)PacketCmd.PKT_S2C_EXTENDED; Write((short)cmd); } }
public SynchVersionRequest(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); cmd = (PacketCmd)reader.ReadByte(); netId = reader.ReadInt32(); unk1 = reader.ReadInt32(); _version = reader.ReadBytes(256); reader.Close(); }
public HeartBeat(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); cmd = (PacketCmd)reader.ReadByte(); netId = reader.ReadInt32(); receiveTime = reader.ReadSingle(); ackTime = reader.ReadSingle(); reader.Close(); }
public uint TargetNetId; // netId on which the player clicked public Click(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { _cmd = (PacketCmd)reader.ReadByte(); _netId = reader.ReadInt32(); Zero = reader.ReadInt32(); TargetNetId = reader.ReadUInt32(); } }
public SynchVersionRequest(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { Cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadInt32(); ClientId = reader.ReadUInt32(); _version = reader.ReadBytes(256); } }
public void SendDataPacketInPipe(PacketCmd cmd, int resend, byte[] buff, int offset, int len) { if (COM.IsOpen) { byte[] packet = BuildDataPack(cmd, buff, offset, len); ByteStream b = new ByteStream(5); b.WriteByte(0); b.WriteDWord(resend); } }
public SwapItemsRequest(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { Cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadInt32(); SlotFrom = reader.ReadByte(); SlotTo = reader.ReadByte(); } }
public HeartBeat(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { Cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadInt32(); ReceiveTime = reader.ReadSingle(); AckTime = reader.ReadSingle(); reader.Close(); } }
internal IPacketHandler GetHandler(PacketCmd cmd, Channel channelID) { if (_handlerTable.ContainsKey(cmd)) { var handlers = _handlerTable[cmd]; if (handlers.ContainsKey(channelID)) { return(handlers[channelID]); } } return(null); }
protected BasePacket(PacketCmd cmd = PacketCmd.PKT_KeyCheck, uint netId = 0) : base(cmd) { buffer.Write((uint)netId); if ((short)cmd > 0xFF) // Make an extended packet instead { var oldPosition = buffer.BaseStream.Position; buffer.BaseStream.Position = 0; buffer.BaseStream.Write(new byte[] { (byte)PacketCmd.PKT_S2C_Extended }, 0, 1); buffer.BaseStream.Position = oldPosition; buffer.Write((short)cmd); } }
public uint targetNetId; // If 0, use coordinates, else use target net id public CastSpellRequest(byte[] data) { var reader = new BinaryReader(new MemoryStream(data)); cmd = (PacketCmd)reader.ReadByte(); netId = reader.ReadInt32(); spellSlotType = reader.ReadByte(); spellSlot = reader.ReadByte(); x = reader.ReadSingle(); y = reader.ReadSingle(); x2 = reader.ReadSingle(); y2 = reader.ReadSingle(); targetNetId = reader.ReadUInt32(); }
public MovementRequest(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { Cmd = (PacketCmd)reader.ReadByte(); NetIdHeader = reader.ReadInt32(); Type = (MovementType)reader.ReadByte(); X = reader.ReadSingle(); Y = reader.ReadSingle(); TargetNetId = reader.ReadUInt32(); CoordCount = reader.ReadByte(); NetId = reader.ReadInt32(); MoveData = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position)); } }
public uint TargetNetId; // If 0, use coordinates, else use target net id public CastSpellRequest(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { Cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadInt32(); SpellSlotType = reader.ReadByte(); SpellSlot = reader.ReadByte(); X = reader.ReadSingle(); Y = reader.ReadSingle(); X2 = reader.ReadSingle(); Y2 = reader.ReadSingle(); TargetNetId = reader.ReadUInt32(); } }
public PingLoadInfoRequest(byte[] data) { using (var reader = new BinaryReader(new MemoryStream(data))) { Cmd = (PacketCmd)reader.ReadByte(); NetId = reader.ReadUInt32(); Position = reader.ReadInt32(); UserId = reader.ReadInt64(); Loaded = reader.ReadSingle(); Unk2 = reader.ReadSingle(); Ping = reader.ReadInt16(); Unk3 = reader.ReadInt16(); Unk4 = reader.ReadByte(); } }