Exemple #1
0
        public override void OnClientData(ClientBase aClient, byte[] data)
        {
            LoginClient client = aClient as LoginClient;
            BinReader   read   = new BinReader(data);

            read.BaseStream.Position += 2;             // skip len
            CMSG msgID = (CMSG)read.ReadInt32();

            if (!LoginPacketManager.HandlePacket(client, msgID, read))
            {
                if (client.WorldConnection != null)
                {
                    ClientPacket pkg = new ClientPacket(msgID, client.Character.ObjectId, data, 6, data.Length - 6);
                    client.SendWorldServer(pkg);
                }
            }
        }
        public override void OnClientData(ClientBase aClient, byte[] data)
        {
            LoginClient client = aClient as LoginClient;
            BinReader   read   = new BinReader(data);
            CMSG        msgID;

            if (client.Authenticated == true)
            {
                // Why do we discard the first two bytes?
                read.BaseStream.Position += 2;
                byte[] header = read.ReadBytes(4);
                client.Decode(header, 4);
                BinReader decoded = new BinReader(header);
                msgID = (CMSG)decoded.ReadInt32();

                /*BinReader ops = new BinReader(client.m_opcode);
                 * msgID = (CMSG)ops.ReadInt32();*/
            }
            else
            {
                read.BaseStream.Position += 2;                 // skip len
                msgID = (CMSG)read.ReadInt32();
            }

//			Console.WriteLine("CMSG:"+ msgID.ToString()); // log opcode to console
            if (!LoginPacketManager.HandlePacket(client, msgID, read))
            {
                Console.WriteLine("Login Handler not found for CMSG " + msgID + " ..sending to worldserver");               // report error

                if (client.WorldConnection != null)
                {
                    ClientPacket pkg = new ClientPacket(msgID, client.Character.ObjectId, data, 6, data.Length - 6);
                    client.SendWorldServer(pkg);
                }
            }
        }