private void OnCustomNotificationReceived(object sender, CustomNotificationReceivedEventArgs e) { using (Trace.Main.scope()) { try { // This is a request for this agent to join a Vidyo conversation if (e.Message.ObjectId.Equals(_session.UserId, StringComparison.InvariantCultureIgnoreCase) && e.Message.EventId.ToLower().Equals(JoinVidyoConferenceRequestEid, StringComparison.InvariantCultureIgnoreCase)) { HandleJoinVidyoConferenceRequest(e); return; } // This is a response for this agent to join a Vidyo conversation if (e.Message.ObjectId.Equals(_session.UserId, StringComparison.InvariantCultureIgnoreCase) && e.Message.EventId.ToLower().Equals(JoinVidyoConferenceResponseEid, StringComparison.InvariantCultureIgnoreCase)) { HandleJoinVidyoConferenceResponse(e); return; } // This is a response with the vidyo base URL if (e.Message.ObjectId.Equals(_session.UserId, StringComparison.InvariantCultureIgnoreCase) && e.Message.EventId.ToLower().Equals(VidyoServiceClientBaseUrlResponseEid, StringComparison.InvariantCultureIgnoreCase)) { var data = e.Message.ReadStrings(); if (data.Length != 1) { throw new Exception("Did not get correct data back from VidyoServiceClientBaseUrlResponseEid request!"); } VidyoServiceClient.BaseUrl = data[0]; return; } // If we got here, bad news. Trace.Main.warning("Unexpected notification received! OID: " + e.Message.ObjectId + ", EID: " + e.Message.EventId); } catch (Exception ex) { Trace.Main.exception(ex); } } }
private void HandleJoinVidyoConferenceRequest(CustomNotificationReceivedEventArgs e) { /* Get data * [0] = Requesting user * [1] = Message from user * [2] = Join url (guest link) */ var data = e.Message.ReadStrings(); if (data.Length != 3) { throw new Exception("Invalid data members! Expected 3 string parameters, got " + data.Length); } var requestingUsername = data[0]; var requestMessage = data[1]; var joinUrl = data[2]; var result = MessageBox.Show(requestingUsername + " has invited you to join a video conference." + Environment.NewLine + "Message: " + requestMessage + Environment.NewLine + Environment.NewLine + "Do you wish to join this conference?", "Video conference invitation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (result != MessageBoxResult.Yes) { // Send decline message SendCustomNotification(CustomMessageType.ApplicationResponse, requestingUsername, JoinVidyoConferenceResponseEid, _session.UserId, "Request rejected"); return; } // Launch URL for user Process.Start(MakeRoomUrl(joinUrl, FormatAgentName(_session.UserId))); }
private void HandleJoinVidyoConferenceResponse(CustomNotificationReceivedEventArgs e) { /* Get data * [0] = Responding user * [1] = Message from user */ var data = e.Message.ReadStrings(); if (data.Length != 2) { throw new Exception("Invalid data members! Expected 2 string parameters, got " + data.Length); } var respondingUsername = data[0]; var requestMessage = data[1]; MessageBox.Show(respondingUsername + " has declined your invitation." + Environment.NewLine + "Message: " + requestMessage, "Video conference invitation rejected", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK); }