Ejemplo n.º 1
0
        public static void OpCode(Decode state, Client ed)
        {
            try
            {
                LogConsole.Show(LogType.DEBUG, "OpCode()");
                Systems sys = (Systems)state.Packet;
                sys.PacketInformation = state;

                ByteQueue queue = ed.queue;

                int length = queue.Length;
                LogConsole.Show(LogType.DEBUG, "OpCode() {0}", length);
                while ((length > 0))
                {
                    byte[] buffer;
                    int    packetID          = queue.GetPacketID();
                    int    packetLength      = queue.GetPacketLength();
                    int    packetControlCode = queue.GetPacketControlCode();

                    LogConsole.Show(LogType.DEBUG, "PacketControl: {0} PacketID: 0x{1:X2} Length: {2}", packetControlCode, packetID, packetLength);
                    LogConsole.HexDump(state.buffer, "", 16);

                    PacketHandler handler = PacketHandlers.GetHandler(packetID);
                    if (handler == null)
                    {
                        byte[] buffer2 = new byte[length];
                        length = queue.Dequeue(buffer2, 0, length);
                        LogConsole.Show(LogType.DEBUG, "Client: {0}: Unhandled packet 0x{1:X2}", new object[] { state, packetID });
                        break;
                    }

                    int size = handler.Length;
                    if (length >= 4)
                    {
                        size = packetLength;
                        if (packetLength >= 4)
                        {
                            if (length < size)
                            {
                                break;
                            }

                            if (0x400 >= size)
                            {
                                buffer = m_Buffers.AquireBuffer();
                            }
                            else
                            {
                                buffer = new byte[size];
                            }

                            size = queue.Dequeue(buffer, 0, size);

                            ushort packetid = ByteQueue.GetPacketID(buffer);

                            bool flag = IsCrypted(packetid);
                            if (flag)
                            {
                                LogConsole.Show(LogType.DEBUG, "Crypted Packet 0x{0:X4}", new object[] { packetid });
                            }

                            try
                            {
                                PacketReader2 pr = new PacketReader2(buffer, size);
                                handler.OnReceive(ed, pr);
                            }
                            catch { break; }

                            length = queue.Length;
                            if ((0x400 >= size) && !flag)
                            {
                                m_Buffers.ReleaseBuffer(buffer);
                                break;
                            }
                        }
                    }

                    length = 0;
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
 public void _OnReceiveData(Systems.Decode de, Systems.Client ed)
 {
     Systems.OpCode(de, ed);
 }
Ejemplo n.º 3
0
 public void _OnClientConnect(ref object de, Systems.Client net)
 {
     LogConsole.Show(LogType.DEBUG, "_OnClientConnect");
     de = new Systems(net);
 }
Ejemplo n.º 4
0
 public void _OnClientConnect(ref object de, Systems.Client net)
 {
     LogConsole.Show(LogType.DEBUG, "_OnClientConnect");
     de = new Systems(net);
 }
Ejemplo n.º 5
0
 public void _OnReceiveData(Systems.Decode de, Systems.Client ed)
 {
     Systems.OpCode(de, ed);
 }