Ejemplo n.º 1
0
 public override void HandleReceived(byte[] data)
 {
     PacketReader reader = new PacketReader(data, 0);
     short opcode = reader.ReadInt16();
     PacketHandler<LoginConnection> handler = DelegateList.LHandlers[opcode];
     if (handler != null)
         handler.OnReceive(this, reader);
     else
         Logger.Trace("Received Undefined Packet 0x{0:x2", opcode);
 }
Ejemplo n.º 2
0
        private static void Handle_RegisterGameServer(GameConnection net, PacketReader reader)
        {
            byte id = reader.ReadByte();
            short port = reader.ReadInt16();

            string ip = reader.ReadDynamicString();
            string password = reader.ReadDynamicString();

            bool success = GameServerController.RegisterGameServer(id, password, net, port, ip);
            net.SendAsync(new NET_GameRegistrationResult(success));
        }
Ejemplo n.º 3
0
 public override void HandleReceived(byte[] data)
 {
     PacketReader reader = new PacketReader(data, 0);
     short opcode = reader.ReadInt16();
     PacketHandler<GameConnection> handler = PacketList.GHandlers[opcode];
     if (handler != null) {
         handler.OnReceive(this, reader);
     }
     else
         Logger.Trace("Received Undefined GameServer Packet 0x{0:X2}", opcode);
     reader = null;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Reading Length And Handles Data By [HandleReceived(byte[])] Without Length.
        /// </summary>
        /// <param name="e"></param>
        private void ProceedReceiving(SocketAsyncEventArgs e)
        {
            int transfered = e.BytesTransferred;
            if (e.SocketError != SocketError.Success || transfered <= 0)
            {
                if (DisconnectedEvent != null)
                    DisconnectedEvent(this, EventArgs.Empty);
                return;
            }

            #if DEBUG
            //--- Console Hexadecimal
            StringBuilder builder = new StringBuilder();
            builder.Append("\n");
            for (int i = 0; i < transfered; i++)
                builder.AppendFormat("{0:x2} ".ToUpper(), m_RecvBuffer[i]);

            Logger.Trace(builder.ToString());
            //--- Console Hexadecimal
            #endif

            PacketReader reader = new PacketReader(m_RecvBuffer, 0);
            short length = m_LittleEndian ? reader.ReadLEInt16() : reader.ReadInt16();

            byte[] data = new byte[length];
            Buffer.BlockCopy(m_RecvBuffer, 2, data, 0, length);
            HandleReceived(data);
            reader = null;
        }