コード例 #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();
        }
コード例 #2
0
 public void Register(BlockingQueue <T> queue)
 {
     _queues.Add(queue);
 }
コード例 #3
0
 public void Unregister(BlockingQueue <T> queue)
 {
     _queues.Remove(queue);
 }
コード例 #4
0
 public void SendExcept(T obj, BlockingQueue <T> except)
 {
     SendExcept(obj, new[] { except });
 }