/// <summary> /// Event fired when the participants collection has been updated. /// </summary> /// <param name="sender">Participants collection.</param> /// <param name="args">Event args containing added and removed participants.</param> private void ParticipantsOnUpdated(ICallParticipantCollection sender, CollectionEventArgs <ICallParticipant> args) { foreach (var participant in args.AddedResources) { var outcome = Serializer.SerializeObject(participant.Resource); this.OutcomesLogMostRecentFirst.AddFirst("Participant Added:\n" + outcome); // todo remove the cast with the new graph implementation, // for now we want the bot to only subscribe to "real" participants var participantDetails = participant.Resource.Info.Identity.User; if (participantDetails != null) { // subscribe to the participant updates, this will indicate if the user started to share, // or added another modality participant.OnUpdated += this.OnParticipantUpdated; // the behavior here is to avoid subscribing to a new participant video if the VideoSubscription cache is full this.SubscribeToParticipantVideo(participant, forceSubscribe: false); } } foreach (var participant in args.RemovedResources) { var participantDetails = participant.Resource.Info.Identity.User; if (participantDetails != null) { // unsubscribe to the participant updates participant.OnUpdated -= this.OnParticipantUpdated; this.UnsubscribeFromParticipantVideo(participant); } var outcome = Serializer.SerializeObject(participant.Resource); this.OutcomesLogMostRecentFirst.AddFirst("Participant Removed:\n" + outcome); } }
/// <summary> /// The event handler when participants are updated. /// </summary> /// <param name="sender">The sender</param> /// <param name="args">The arguments</param> private void OnParticipantsUpdated(ICallParticipantCollection sender, CollectionEventArgs <ICallParticipant> args) { foreach (var participant in args.AddedResources) { var outcome = Serializer.SerializeObject(participant.Resource); this.OutcomesLogMostRecentFirst.AddFirst("Participant Added:\n" + outcome); participant.OnUpdated += this.OnParticipantUpdated; } foreach (var participant in args.RemovedResources) { var outcome = Serializer.SerializeObject(participant.Resource); this.OutcomesLogMostRecentFirst.AddFirst("Participant Removed:\n" + outcome); participant.OnUpdated -= this.OnParticipantUpdated; } this.ParticipantsOnUpdated(sender, args); }
/// <summary> /// Event triggered when participants collection is updated. /// </summary> /// <param name="sender">Call Participants collection.</param> /// <param name="args">Event args containing the added participants and removed participants.</param> private void OnParticipantsUpdated(ICallParticipantCollection sender, CollectionEventArgs <ICallParticipant> args) { foreach (var participant in args.AddedResources) { var outcome = Serializer.SerializeObject(participant.Resource); this.OutcomesLogMostRecentFirst.AddFirst("Participant Added:\n" + outcome); participant.OnUpdated += this.OnParticipantUpdated; } foreach (var participant in args.RemovedResources) { var outcome = Serializer.SerializeObject(participant.Resource); this.OutcomesLogMostRecentFirst.AddFirst("Participant Removed:\n" + outcome); participant.OnUpdated -= this.OnParticipantUpdated; } // Subscribed participant might have left the meeting. this.Subscribe(); }
/// <inheritdoc/> protected override void ParticipantsOnUpdated(ICallParticipantCollection sender, CollectionEventArgs <ICallParticipant> args) { foreach (var participant in args.AddedResources) { var responderId = participant.Resource?.Info?.Identity?.User?.Id; if (responderId == null) { // the participant have no user ID (ex. it is a bot). continue; } this.statusData?.UpdateResponderMeetingCallId(responderId, this.Call.Id, this.Call.CorrelationId); this.statusData?.UpdateResponderMeetingStatus(responderId, IncidentResponderMeetingStatus.Added); var responderCallId = this.statusData?.GetResponder(responderId)?.NotificationCallId; if (responderCallId != null) { this.TryDeleteCall(responderCallId); } } foreach (var participant in args.RemovedResources) { var responderId = participant.Resource?.Info?.Identity?.User?.Id; if (responderId == null) { // the participant have no user ID (ex. it is a bot). continue; } this.statusData?.UpdateResponderMeetingStatus(responderId, IncidentResponderMeetingStatus.Removed); } }
/// <summary> /// The event handler when participants are updated. /// </summary> /// <param name="sender">The sender</param> /// <param name="args">The arguments</param> protected virtual void ParticipantsOnUpdated(ICallParticipantCollection sender, CollectionEventArgs <ICallParticipant> args) { // do nothing in base class. }