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; } }
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); }
private void OnDisconnected(object sender, EventArgs e) { m_serverSocket = null; }