예제 #1
0
        private void ListenThread()
        {
            while (true)
            {
                try
                {
                    listenerSocket.Listen(0);

                    ClientBase client = CreateClient(listenerSocket.Accept());

                    clientCounter++;
                    clientTable.Add(client, clientCounter);
                    clientFromId.Add(clientCounter, client);

                    client.MessageReceived += Client_MessageReceived;
                    client.ConnectionEnded += Client_ConnectionEnded;

                    ClientConnected?.Invoke(this, new ClientConnectedEventArgs(client, clientCounter));
                }
                catch (SocketException)
                {
                    ListenerClosed?.Invoke(this, new EventArgs());
                    return;
                }
            }
        }
예제 #2
0
        public void CloseSubscriber()
        {
            using (log.Block())
            {
                subscriberHosts.ForEach(host => host.Close());
                subscriberHosts.Clear();
            }

            ListenerClosed?.Invoke();
        }
예제 #3
0
 private void OnListenerClosed(Listener listener)
 {
     ListenerClosed?.Invoke(this, listener);
 }