Пример #1
0
 // Called when a message is received from a client
 protected void Client_MessageReceived(Client Sender, Message Msg)
 {
     if (BufferMessages) // Store message in message queue
         Messages.Add(new ClientMessagePair(Sender, Msg));
     else // Fire message received event
         ClientMessageReceived(this, Sender, Msg);
 }
Пример #2
0
 public ClientMessagePair(Client Client, Message Message)
 {
     this.Client = Client;
     this.Message = Message;
 }
Пример #3
0
        protected void Client_Disconnect(Client Sender, DisconnectMessage Msg)
        {
            // Detach event handlers
            Sender.Disconnect -= Client_Disconnect;
            Sender.MessageReceived -= Client_MessageReceived;

            Sender.Dispose();

            lock (Clients) // Thread safe
                Clients.Remove(Sender);

            // Fire disconnection event
            ClientDisconnect(this, Sender, Msg);
        }