コード例 #1
0
ファイル: ChatService.cs プロジェクト: killerwife/ACMadness
        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;
        }
コード例 #2
0
ファイル: ChatService.cs プロジェクト: killerwife/ACMadness
 public void Say(Message msg)
 {
     lock (syncObj)
     {
         foreach (IChatCallback callback in clients.Values)
         {
             callback.Receive(msg);
         }
     }
 }
コード例 #3
0
ファイル: ChatService.cs プロジェクト: killerwife/ACMadness
        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;
                        }
                    }
                }
            }
        }
コード例 #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);
 }