Esempio n. 1
0
        /// <summary>
        /// 有实例产生时调用
        /// </summary>
        /// <param name="clientSocket"></param>
        public NetState(ClientSession <NetState> clientSocket)
            : this()
        {
            if (clientSocket == null)
            {
                throw new ArgumentNullException("clientSocket", "NetState.NetState(...) - clientSocket == null error!");
            }

            m_Socket      = clientSocket;
            m_Socket.Data = this;

            //IPAddress ipAddress;
            //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);

            ReceiveBuffer              = new ReceiveQueue();
            m_Socket.SocketConnect    += m_Socket_SocketConnect;
            m_Socket.SocketDisconnect += m_Socket_SocketDisconnect;
        }
Esempio n. 2
0
        /// <summary>
        /// 有实例产生时调用
        /// </summary>
        /// <param name="clientSocket"></param>
        public NetState(ClientSession<NetState> clientSocket)
            : this()
        {
            if (clientSocket == null)
                throw new ArgumentNullException("clientSocket", "NetState.NetState(...) - clientSocket == null error!");

            m_Socket = clientSocket;
            m_Socket.Data = this;

            //IPAddress ipAddress;
            //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);

            ReceiveBuffer = new ReceiveQueue();
            m_Socket.SocketConnect += m_Socket_SocketConnect;
            m_Socket.SocketDisconnect += m_Socket_SocketDisconnect;
        }