示例#1
0
        private static void OnReceive(UDPReceiver receiver, SocketAsyncEventArgs e)
        {
            var remoteEP = (IPEndPoint)e.RemoteEndPoint;

            if (e.BytesTransferred < 2)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("[{0:yyyy-MM-dd HH\\:mm\\:ss}] [{1}:{2}] Invalid message received", DateTime.Now, remoteEP.Address, remoteEP.Port);
                Console.ForegroundColor = ConsoleColor.Gray;
                return;
            }
            UInt16 packetID = receiver.ReadUint16();
            var    handler  = ReceiveOpcodes.GetOpcodeHandler(packetID);

            if (handler == null)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("[{0:yyyy-MM-dd HH\\:mm\\:ss}] [{1}:{2}] Unknown Opcode {3}", DateTime.Now, remoteEP.Address, remoteEP.Port, packetID);
                Console.ForegroundColor = ConsoleColor.Gray;
                return;
            }

            var session = Session.GetInstance(remoteEP, s => { s.Data = new ClientInfo(); });

            handler.OnReceive(session, receiver);
        }
示例#2
0
        public static void RegisterOpcodes()
        {
            ReceiveOpcodes.StoreOpcode((UInt16)CMSG_AUTH_LOGON_CHALLENGE, new OpcodeDelegate(OnLogonChallenge));
            ReceiveOpcodes.StoreOpcode((UInt16)CMSG_AUTH_LOGON_PROOF, new OpcodeDelegate(OnLogonProof));

            ReceiveOpcodes.StoreOpcode((UInt16)CMSG_REALMLIST, new OpcodeDelegate(OnRealmList));
        }
示例#3
0
        public static void RegisterOpcodes()
        {
            ReceiveOpcodes.StoreOpcode((UInt16)SMSG_AUTH_LOGON_CHALLENGE_OK, new OpcodeDelegate(OnLogonChallengeOK));
            ReceiveOpcodes.StoreOpcode((UInt16)SMSG_AUTH_LOGON_CHALLENGE_FAIL, new OpcodeDelegate(OnLogonChallengeFail));
            ReceiveOpcodes.StoreOpcode((UInt16)SMSG_AUTH_LOGON_PROOF_OK, new OpcodeDelegate(OnLogonProofOK));
            ReceiveOpcodes.StoreOpcode((UInt16)SMSG_AUTH_LOGON_PROOF_FAIL, new OpcodeDelegate(OnLogonProofFail));

            // ReceiveOpcodes.StoreOpcode((UInt16)SMSG_REALMLIST_RESPONSE, new OpcodeDelegate(OnRealmListResponse));
        }