Exemplo n.º 1
0
 public PacketOut(WorldServerOpCode opcode)
     : base(new MemoryStream())
 {
     packetId = new PacketId(opcode);
     Service = ServiceType.World;
     this.Write((uint)opcode);
 }
Exemplo n.º 2
0
 public PacketWriter(WorldServerOpCode opcode)
     : base(new MemoryStream())
 {
     Opcode  = opcode;
     Opcode2 = (short)opcode;
     //this.Write((uint)opcode);
 }
Exemplo n.º 3
0
 public PacketOut(WorldServerOpCode opcode)
     : base(new MemoryStream())
 {
     packetId = new PacketId(opcode);
     Service  = ServiceType.World;
     this.Write((uint)opcode);
 }
Exemplo n.º 4
0
    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);
        }
    }
Exemplo n.º 5
0
 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);
     }
 }
Exemplo n.º 6
0
 public PacketId(WorldServerOpCode id)
 {
     Service = ServiceType.World;
     RawId = (uint)id;
 }
Exemplo n.º 7
0
 public PacketHandlerAtribute(WorldServerOpCode opcode)
 {
     this.PacketID = new PacketId(opcode);
 }
Exemplo n.º 8
0
 public PacketHandlerAtribute(WorldServerOpCode opcode)
 {
     this.PacketID = new PacketId(opcode);
 }
Exemplo n.º 9
0
 public static void DefineOpcodeHandler(WorldServerOpCode opcode, HandlePacket handler)
 {
     OpcodeHandlers[opcode] = handler;
 }
Exemplo n.º 10
0
 public PacketId(WorldServerOpCode id)
 {
     Service = ServiceType.World;
     RawId   = (uint)id;
 }