Ejemplo n.º 1
0
 private void BeginTryToConnectParticipant(Participant participant, string nickname)
 {
     participant.BeginSend(new Message(nickname), () =>
     {
         participant.BeginReceive(OnMessage, exception => { throw exception; });
     }, OnError);
 }
Ejemplo n.º 2
0
 private static void OnReceiveMessage(Message message)
 {
     participant.Nickname = message.ToString();
     if (room.Join(participant))
     {
         Console.WriteLine("--" + participant.Nickname + "--");
         participant.BeginSend(new Message("Yes"), () =>
         {
             participant.BeginSend(new Message(room.GetParticipantsNicknames()), () =>
             {
                 BroadcastMessage(participant);
             }, OnError);
         }, OnError);
     }
     else
     {
         participant.BeginSend(new Message("No"), () =>
         {
             TryToReceive(participant);
         }, OnError);
     }
 }
Ejemplo n.º 3
0
 private void BeginWrite(Participant participant, string text)
 {
     try
     {
         if (text == string.Empty)
         {
             throw new EmptyMessageException();
         }
         Message message = new Message(text);
         participant.BeginSend(message, () =>
         {
             Dispatcher.Invoke(() => messageBox.Text = string.Empty);
         }, OnBeginWriteError);
     }
     catch (EmptyMessageException exception)
     {
         OnBeginWriteError(exception);
     }
 }