internal void RemoveClientConnection(AsyncClientConnection connection, string reason) { if (!connection.Client.Connected) { ClientConnections.Remove(connection); if (OnClientDisconnect != null) { OnClientDisconnect(connection, reason); } Log("Client disconnected"); } }
private void WaitForIncomingConnections() { Log("Listening for new connections."); while (true) { AsyncClientConnection connection = new AsyncClientConnection(this); connection.Connect(Listener.AcceptTcpClient()); Log("Client connected at " + connection.Host); ClientConnections.Add(connection); if (OnClientConnection != null) { OnClientConnection(connection); } } }
internal void ProcessIncominData(string data, AsyncClientConnection connection) { Log(data); if (data == null) { connection.Disconnect(); } else if (data.Equals("PING")) { connection.SendData("PONG"); Log("Replying with PONG"); } else { if (OnClientInputEvent != null) { OnClientInputEvent(connection, data); } } }