private void BeginTryToConnectParticipant(Participant participant, string nickname) { participant.BeginSend(new Message(nickname), () => { participant.BeginReceive(OnMessage, exception => { throw exception; }); }, OnError); }
private static void BroadcastMessage(Participant participant) { participant.BeginReceive(messageReceived => { room.Broadcast(new Message(participant.Nickname + ": " + messageReceived)); BroadcastMessage(participant); }, OnError); }
private void TryToLogin(string nickname) { var loginWindow = new LoginWindow(nickname); Hide(); loginWindow.ShowDialog(); participant = loginWindow.GetParticipant(); client = loginWindow.GetClient(); if (participant == null) { Application.Current.Shutdown(); } else { participant.BeginReceive(OnParticipants, OnError); } }
private void BeginReceive(Participant participant) { participant.BeginReceive(value => { string text = value.ToString(); if (CheckOnlineParticipants(text)) { UpdateOnlineParticipants(); } text = CheckSpecialMessage(text); Dispatcher.Invoke(() => { messageChatBox.Text += text + "\n"; messageIssues.Text = string.Empty; }); BeginReceive(participant); }, OnErrorMessageBox); }
private static void TryToReceive(Participant participant) { participant.BeginReceive(OnReceiveMessage, OnError); }