/// <inheritdoc/> protected override void ParticipantsOnUpdated(IParticipantCollection sender, CollectionEventArgs <IParticipant> 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.ScenarioId); * * 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; } } }
/// <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(IParticipantCollection sender, CollectionEventArgs <IParticipant> args) { foreach (var participant in args.AddedResources) { // 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); } } }
/// <summary> /// The event handler when participants are updated. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The arguments.</param> private void OnParticipantsUpdated(IParticipantCollection sender, CollectionEventArgs <IParticipant> args) { var request = new { Type = "participants_update", Content = args }; string jsonString = JsonSerializer.Serialize(request); using (var client = new HttpClient()) { var response = client.PostAsync("https://ngage.eastus2.cloudapp.azure.com:2145/teamsbot", new StringContent(jsonString, Encoding.UTF8, "application/json")).Result; if (response.IsSuccessStatusCode) { var responseContent = response.Content; string responseString = responseContent.ReadAsStringAsync().Result; Console.WriteLine(responseString); } } foreach (var participant in args.AddedResources) { participant.OnUpdated += this.OnParticipantUpdated; } foreach (var participant in args.RemovedResources) { participant.OnUpdated -= this.OnParticipantUpdated; } this.ParticipantsOnUpdated(sender, args); }
/// <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> public void ParticipantsOnUpdated(IParticipantCollection sender, CollectionEventArgs <IParticipant> args) { if (_settings.CaptureEvents) { _capture?.Append(args); } updateParticipants(args.AddedResources); updateParticipants(args.RemovedResources, false); }
/// <summary> /// The event handler when participants are updated. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The arguments.</param> private void OnParticipantsUpdated(IParticipantCollection sender, CollectionEventArgs <IParticipant> args) { foreach (var participant in args.AddedResources) { participant.OnUpdated += this.OnParticipantUpdated; } foreach (var participant in args.RemovedResources) { participant.OnUpdated -= this.OnParticipantUpdated; } this.ParticipantsOnUpdated(sender, args); }
/// <summary> /// Waits for the specified participant to be removed from the call asynchronously. /// </summary> /// <param name="participants">The participants collection.</param> /// <param name="match">The match function.</param> /// <param name="failureMessage">The failure message.</param> /// <param name="timeOut">The time out.</param> /// <returns> /// The removed <see cref="IParticipant" />. /// </returns> public static Task <IParticipant> WaitForRemovedParticipantAsync( this IParticipantCollection participants, Func <IParticipant, bool> match, string failureMessage = null, TimeSpan timeOut = default(TimeSpan)) { failureMessage = failureMessage ?? $"Timed out while waiting for participant to be removed from collection {participants.ResourcePath}"; return(participants.WaitForUpdateAsync <IParticipantCollection, IParticipant, Participant>( args => args.RemovedResources.FirstOrDefault(match), failureMessage, timeOut)); }
/// <summary> /// Waits for the specified participant to join the call asynchronously. /// </summary> /// <param name="participants">The participants collection.</param> /// <param name="participantId">The participant identifier.</param> /// <param name="failureMessage">The failure message.</param> /// <param name="timeOut">The time out.</param> /// <returns> /// The joined <see cref="IParticipant" />. /// </returns> public static Task <IParticipant> WaitForParticipantAsync( this IParticipantCollection participants, string participantId, string failureMessage = null, TimeSpan timeOut = default(TimeSpan)) { failureMessage = failureMessage ?? $"Timed out while waiting for participant {participantId} in collection {participants.ResourcePath}"; return(participants.WaitForParticipantAsync( participant => participantId.EqualsIgnoreCase(participant.Resource.Id), failureMessage, timeOut)); }
/// <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(IParticipantCollection sender, CollectionEventArgs <IParticipant> args) { foreach (var participant in args.AddedResources) { participant.OnUpdated += this.OnParticipantUpdated; } foreach (var participant in args.RemovedResources) { participant.OnUpdated -= this.OnParticipantUpdated; } // Subscribed participant might have left the meeting. this.Subscribe(); }
private void OnParticipantsUpdated(IParticipantCollection sender, CollectionEventArgs <IParticipant> args) { foreach (var participant in args.AddedResources) { participant.OnUpdated += this.OnParticipantUpdated; uint msi = (uint)Int32.Parse(participant.Resource.MediaStreams.FirstOrDefault(stream => stream.MediaType == Modality.Audio).SourceId); this.subscribedToMsi = msi; this.Subscribe(msi); } foreach (var participant in args.RemovedResources) { participant.OnUpdated -= this.OnParticipantUpdated; } bool nonBotParticipants = false; foreach (var participant in sender) { var isBot = participant.Resource.Info.Identity.Application != null; if (!isBot) { nonBotParticipants = true; break; } } if (nonBotParticipants) { this.endCallTimer.Stop(); } else { this.endCallTimer.Start(); } this.Subscribe(); }
/// <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(IParticipantCollection sender, CollectionEventArgs <IParticipant> args) { foreach (var participant in args.AddedResources) { participant.OnUpdated += this.OnParticipantUpdated; } foreach (var participant in args.RemovedResources) { participant.OnUpdated -= this.OnParticipantUpdated; } bool nonBotParticipants = false; foreach (var participant in sender) { var isBot = participant.Resource.Info.Identity.Application != null; if (!isBot) { nonBotParticipants = true; break; } } if (nonBotParticipants) { this.endCallTimer.Stop(); } else { this.endCallTimer.Start(); } // Subscribed participant might have left the meeting. this.Subscribe(); }
/// <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(IParticipantCollection sender, CollectionEventArgs <IParticipant> args) { // do nothing in base class. }
/// <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> public void ParticipantsOnUpdated(IParticipantCollection sender, CollectionEventArgs <IParticipant> args) { UpdateParticipants(args.AddedResources); UpdateParticipants(args.RemovedResources, false); }