Beispiel #1
0
        public ClientHandler(Socket socket, BroadcastBlockingQueue <Message> broadcastQueue)
        {
            _socket         = socket;
            _broadcastQueue = broadcastQueue;

            Name = $"Anonymous{Random.Next(10000, 99999)}";

            _messageQueue = new BlockingQueue <Message>();
            _broadcastQueue.Register(_messageQueue);

            _sendThread = new Thread(SendProc)
            {
                IsBackground = true
            };
            _sendThread.Start();

            _receiveThread = new Thread(ReceiveProc)
            {
                IsBackground = true
            };
            _receiveThread.Start();
        }
 public void Register(BlockingQueue <T> queue)
 {
     _queues.Add(queue);
 }
 public void Unregister(BlockingQueue <T> queue)
 {
     _queues.Remove(queue);
 }
 public void SendExcept(T obj, BlockingQueue <T> except)
 {
     SendExcept(obj, new[] { except });
 }