Esempio n. 1
0
        public bool SendFile(FileMessage fileMsg, Client receiver)
        {
            foreach (Client rcvr in clients.Keys)
            {
                if (rcvr.Name == receiver.Name)
                {
                    Message msg = new Message();
                    msg.Sender = fileMsg.Sender;
                    msg.Content = "I'M SENDING FILE.. " + fileMsg.FileName;

                    IChatCallback rcvrCallback = clients[rcvr];
                    rcvrCallback.ReceiveWhisper(msg, receiver);
                    rcvrCallback.ReceiverFile(fileMsg, receiver);

                    foreach (Client sender in clients.Keys)
                    {
                        if (sender.Name == fileMsg.Sender)
                        {
                            IChatCallback sndrCallback = clients[sender];
                            sndrCallback.ReceiveWhisper(msg, receiver);
                            return true;
                        }
                    }
                }
            }
            return false;
        }
Esempio n. 2
0
 public void Say(Message msg)
 {
     lock (syncObj)
     {
         foreach (IChatCallback callback in clients.Values)
         {
             callback.Receive(msg);
         }
     }
 }
Esempio n. 3
0
        public void Whisper(Message msg, Client receiver)
        {
            foreach (Client rec in clients.Keys)
            {
                if (rec.Name == receiver.Name)
                {
                    IChatCallback callback = clients[rec];
                    callback.ReceiveWhisper(msg, rec);

                    foreach (Client sender in clients.Keys)
                    {
                        if (sender.Name == msg.Sender)
                        {
                            IChatCallback senderCallback = clients[sender];
                            senderCallback.ReceiveWhisper(msg, rec);
                            return;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 public void Whisper(Message msg, string receiver)
 {
     var sender = GetClientByName(msg.Sender);
     var recive = GetClientByName(receiver);
     if (sender.Key == null || recive.Key == null) return;
     sender.Value.ReceiveWhisper(msg, receiver);
     recive.Value.ReceiveWhisper(msg, receiver);
 }