Exemple #1
0
        /// <summary>
        /// 有实例产生时调用
        /// </summary>
        /// <param name="clientSocket"></param>
        /// <param name="messagePump"></param>
        internal NetState(ClientSocketManager clientSocket, MessagePump messagePump)
        {
            if (clientSocket == null)
            {
                throw new ArgumentNullException("clientSocket", "NetState.NetState(...) - clientSocket == null error!");
            }

            if (messagePump == null)
            {
                throw new ArgumentNullException("messagePump", "NetState.NetState(...) - messagePump == null error!");
            }

            if (messagePump.World == null)
            {
                throw new ArgumentNullException("messagePump.World", "NetState.NetState(...) - messagePump.World == null error!");
            }

            m_Socket            = clientSocket;
            m_MessagePump       = messagePump;
            m_ConnectedOn       = OneServer.NowTime;
            m_World             = messagePump.World;
            m_ToString          = clientSocket.Address;
            m_NextCheckActivity = m_ConnectedOn + m_World.CheckAliveTime;

            IPAddress ipAddress = null;

            IPAddress.TryParse(clientSocket.RemoteOnlyIP, out ipAddress);

            if (ipAddress == null)
            {
                m_NetAddress = new IPEndPoint(IPAddress.None, clientSocket.RemotePort);
            }
            else
            {
                m_NetAddress = new IPEndPoint(ipAddress, clientSocket.RemotePort);
            }
        }
Exemple #2
0
        /// <summary>
        /// 有实例产生时调用
        /// </summary>
        /// <param name="clientSocket"></param>
        /// <param name="messagePump"></param>
        internal NetState(ClientSocketManager clientSocket, MessagePump messagePump)
        {
            if (clientSocket == null)
                throw new ArgumentNullException("clientSocket", "NetState.NetState(...) - clientSocket == null error!");

            if (messagePump == null)
                throw new ArgumentNullException("messagePump", "NetState.NetState(...) - messagePump == null error!");

            if (messagePump.World == null)
                throw new ArgumentNullException("messagePump.World", "NetState.NetState(...) - messagePump.World == null error!");

            m_Socket = clientSocket;
            m_MessagePump = messagePump;
            m_ConnectedOn = OneServer.NowTime;
            m_World = messagePump.World;
            m_ToString = clientSocket.Address;
            m_NextCheckActivity = m_ConnectedOn + m_World.CheckAliveTime;

            IPAddress ipAddress = null;
            IPAddress.TryParse(clientSocket.RemoteOnlyIP, out ipAddress);

            if (ipAddress == null)
                m_NetAddress = new IPEndPoint(IPAddress.None, clientSocket.RemotePort);
            else
                m_NetAddress = new IPEndPoint(ipAddress, clientSocket.RemotePort);
        }
Exemple #3
0
        /// <summary>
        /// 无效实例产生时调用
        /// </summary>
        /// <param name="clientSocket"></param>
        /// <param name="messagePump"></param>
        public NetState()
        {
            m_Socket = null;
            m_MessagePump = null;
            m_ConnectedOn = OneServer.NowTime;
            m_World = null;
            m_ToString = "0.0.0.0";
            m_NextCheckActivity = DateTime.MaxValue;

            m_NetAddress = new IPEndPoint(IPAddress.None, 0);

            m_Disposed.SetInvalid();
        }