예제 #1
0
        public void Disconnect()
        {
            if (m_serverSocket != null)
            {
                m_serverSocket.OnClientConnect    -= OnClientConnected;
                m_serverSocket.OnClientDisconnect -= OnClientDisconnected;

                m_serverSocket.OnReceive    -= OnReceived;
                m_serverSocket.OnDisconnect -= OnDisconnected;

                if (m_serverSocket.IsConnected)
                {
                    m_serverSocket.Disconnect();
                }

                m_serverSocket = null;
            }
        }
예제 #2
0
        public void Listen(int port)
        {
            if (m_Port != port && m_serverSocket != null)
            {
                Disconnect();
            }

            m_Port = port;

            m_serverSocket = new TcpServerSocket();

            m_serverSocket.OnClientConnect    += OnClientConnected;
            m_serverSocket.OnClientDisconnect += OnClientDisconnected;

            m_serverSocket.OnReceive    += OnReceived;
            m_serverSocket.OnDisconnect += OnDisconnected;

            m_serverSocket.Listen(m_Port);
        }
예제 #3
0
 private void OnDisconnected(object sender, EventArgs e)
 {
     m_serverSocket = null;
 }