示例#1
0
        private void ConnectionThread()
        {
            try
            {
                while (_processConnectionThread)
                {
                    Socket socket = _serverSocket.Accept();

                    if (_clientManagers == null)
                    {
                        throw new InvalidOperationException(
                                  "Cannot accept new connections, _clientManagers object is not initialised.");
                    }

                    lock (_clientManagers)
                    {
                        ClientManager manager = new ClientManager(socket, ClientManagerMessageSink);
                        manager.DisconnectCallback = ClientDisconnect;

                        _clientManagers.Add(manager);

                        manager.Start();
                    }
                }
            }
#if TRACE
            catch (SocketException socketException)
            {
                Trace.WriteLine(socketException.ToString());
            }
#else
            catch (SocketException)
            {
            }
#endif
        }