Beispiel #1
0
        private void ListenerThread()
        {
            while (true)
            {
                TcpClient client;
                try
                {
                    client = _listener.AcceptTcpClient();
                }
                catch (Exception)
                {
                    break;
                }

                var t = new Thread(() =>
                {
                    var connection = new TCPConnection(client, _settings);
                    if (connection.Authenticate())
                    {
                        Application.Current.Dispatcher.Invoke(() => OnClientConnected(connection));
                        connection.Disconnected += connection_Disconnected;
                        connection.StartListening();
                    }
                });
                t.Start();
            }
        }
Beispiel #2
0
 protected void OnClientDisconnected(TCPConnection connection)
 {
     if (ClientDisconnected != null) ClientDisconnected(this, new TCPConnectionChangedEventArgs(connection));
 }