public PacketOut(WorldServerOpCode opcode) : base(new MemoryStream()) { packetId = new PacketId(opcode); Service = ServiceType.World; this.Write((uint)opcode); }
public PacketWriter(WorldServerOpCode opcode) : base(new MemoryStream()) { Opcode = opcode; Opcode2 = (short)opcode; //this.Write((uint)opcode); }
public void OnData() { try { for (int index = 0; index < DataBuffer.Length; index++) { byte[] headerData = new byte[4]; Array.Copy(DataBuffer, index, headerData, 0, 4); this.Decode(headerData); Array.Copy(headerData, 0, DataBuffer, index, 4); ushort opcode = BitConverter.ToUInt16(headerData, 2); int length = BitConverter.ToInt16(headerData, 0); WorldServerOpCode code = (WorldServerOpCode)opcode; byte[] packetData = new byte[length + 2]; Array.Copy(DataBuffer, index, packetData, 0, length + 2); Debug.LogWarning("<---GOTCHA---<< [" + code + "] Packet Length: " + length); if (Enum.IsDefined(typeof(WorldServerOpCode), code)) { PacketReader pkt = null; PacketQueue.Enqueue(new PacketReader(packetData)); if (PacketQueue.Count > 0) { pkt = (PacketReader)PacketQueue.Dequeue(); pkt.Opcode = code; pkt.Size = (ushort)length; } else { pkt = new PacketReader(packetData); pkt.Opcode = code; pkt.Size = (ushort)length; } PacketManager.InvokeHandler(pkt, this, code); } else { Debug.LogWarning("UNKNOWN OPCODE"); } index += 2 + (length - 1); } } catch (Exception e) { Debug.LogWarning(e.ToString() + " " + e.InnerException); } }
public static bool InvokeHandler(PacketReader reader, World manager, WorldServerOpCode opcode) { if (OpcodeHandlers.ContainsKey(opcode)) { OpcodeHandlers[opcode].Invoke(ref reader, ref manager); return(true); } else { return(false); } }
public PacketId(WorldServerOpCode id) { Service = ServiceType.World; RawId = (uint)id; }
public PacketHandlerAtribute(WorldServerOpCode opcode) { this.PacketID = new PacketId(opcode); }
public static void DefineOpcodeHandler(WorldServerOpCode opcode, HandlePacket handler) { OpcodeHandlers[opcode] = handler; }