Exemple #1
0
        internal void RemoveClientConnection(AsyncClientConnection connection, string reason)
        {
            if (!connection.Client.Connected)
            {
                ClientConnections.Remove(connection);
                if (OnClientDisconnect != null)
                {
                    OnClientDisconnect(connection, reason);
                }

                Log("Client disconnected");
            }
        }
Exemple #2
0
 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);
         }
     }
 }
Exemple #3
0
 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);
         }
     }
 }