Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newNetState"></param>
        internal static void RealmInitializeNetState(object sender, NetStateInitEventArgs netStateInit)
        {
            if (netStateInit.NetStateInit != null)
            {
                // 初始化客户端
                RealmExtendData extendData = new RealmExtendData();

                netStateInit.NetStateInit.RegisterComponent <RealmExtendData>(RealmExtendData.COMPONENT_ID, extendData);

                // 获取包的ID
                netStateInit.NetStateInit.ReceiveBuffer.ThreadEventPacketID += new EventHandler <PacketIdInfoEventArgs>(RealmReceiveQueue_PacketID);

                // 获取包的长度
                netStateInit.NetStateInit.ReceiveBuffer.ThreadEventPacketLength += new EventHandler <PacketLengthInfoEventArgs>(RealmReceiveQueue_PacketLength);

                // 启动登陆Realm服务
                netStateInit.NetStateInit.EventConnect += new EventHandler <NetStateConnectEventArgs>(RealmInitConnect);

                // 截获输出的信息包
                netStateInit.NetStateInit.EventSendPacket += new EventHandler <NetStateSendPacketEventArgs>(RealmSendPacket);

                // 只有一个连接到RealmServer的NetState实例
                ProcessServer.RealmNetState = netStateInit.NetStateInit;
            }
            else
            {
                Debug.WriteLine("ProcessNet.RealmList_InitializeNetState(...) - newNetState != null && newNetState.ExtendData == null error!");
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void Realm_HandleRequestSessionResult(NetState netState, PacketReader packetReader)
        {
            RealmExtendData extendData = netState.GetComponent <RealmExtendData>(RealmExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("Realm_PacketHandlers.Realm_HandleRequestSessionResult(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("Realm_PacketHandlers.Realm_HandleRequestSessionResult(...) - extendData.IsLoggedIn == false error!");
                return;
            }

            uint iSerial = packetReader.ReadUInt32();

            NetState worldNetState = PendingLogins.GetAuthenticate(iSerial);

            if (worldNetState == null)
            {
                Debug.WriteLine("Realm_PacketHandlers.Realm_HandleRequestSessionResult(...) - sendNetState == null error!");
                return;
            }
            PendingLogins.RemoveAuthenticate(iSerial);

            WorldPacketHandlers.InternalCallbackAuthenticate(worldNetState, packetReader);
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void Realm_HandleRegisterRealmResult(NetState netState, PacketReader packetReader)
        {
            RealmExtendData extendData = netState.GetComponent <RealmExtendData>(RealmExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("Realm_PacketHandlers.Realm_HandleRegisterRealmResult(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == true)
            {
                Debug.WriteLine("Realm_PacketHandlers.Realm_HandleRegisterRealmResult(...) - extendData.IsLoggedIn == true error!");
                return;
            }

            uint iRealmSerial = packetReader.ReadUInt32();

            extendData.RegisterRealmResult.Serial = new Serial(iRealmSerial);

            // 已经登陆
            extendData.IsLoggedIn = true;

            // 3分钟 向服务端发一次心跳信号
            TimeSlice.StartTimeSlice(TimerPriority.Lowest, TimeSpan.FromMinutes(3), TimeSpan.FromMinutes(3), new TimeSliceCallback(SendPing));

            LOGs.WriteLine(LogMessageType.MSG_INFO, "RealmServer:登陆RealmServer服务器成功 返回的标示ID({0})", extendData.RegisterRealmResult.Serial.ToString());
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="netState"></param>
        /// <param name="packetReader"></param>
        internal static void Realm_HandlePong(NetState netState, PacketReader packetReader)
        {
            RealmExtendData extendData = netState.GetComponent <RealmExtendData>(RealmExtendData.COMPONENT_ID);

            if (extendData == null)
            {
                Debug.WriteLine("Realm_PacketHandlers.Realm_HandlePong(...) - extendData == null error!");
                return;
            }

            if (extendData.IsLoggedIn == false)
            {
                Debug.WriteLine("Realm_PacketHandlers.Realm_HandlePong(...) - extendData.IsLoggedIn == false error!");
                return;
            }
        }