/// <summary> /// Joins the call asynchronously. /// </summary> /// <param name="joinCallBody">The join call body.</param> /// <param name="incidentId">Incident Id.</param> /// <returns>The <see cref="ICall"/> that was requested to join.</returns> public async Task <ICall> JoinCallAsync(JoinCallRequestData joinCallBody, string incidentId = "") { // A tracking id for logging purposes. Helps identify this call in logs. var scenarioId = string.IsNullOrEmpty(joinCallBody.ScenarioId) ? Guid.NewGuid() : new Guid(joinCallBody.ScenarioId); Microsoft.Graph.MeetingInfo meetingInfo; ChatInfo chatInfo; (chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinURL); var tenantId = joinCallBody.TenantId ?? (meetingInfo as OrganizerMeetingInfo)?.Organizer.GetPrimaryIdentity()?.GetTenantId(); var mediaToPrefetch = new List <MediaInfo>(); foreach (var m in this.MediaMap) { mediaToPrefetch.Add(m.Value.MediaInfo); } var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, new[] { Modality.Audio }, mediaToPrefetch) { TenantId = tenantId, }; var statefulCall = await this.Client.Calls().AddAsync(joinParams, scenarioId).ConfigureAwait(false); this.AddCallToHandlers(statefulCall, "BotMeeting"); this.graphLogger.Info($"Join Call complete: {statefulCall.Id}"); return(statefulCall); }
public async Task <IActionResult> JoinCallAsync([FromBody] JoinCallRequestData joinCallBody) { Validator.NotNull(joinCallBody, nameof(joinCallBody)); try { var call = await this.bot.JoinCallAsync(joinCallBody).ConfigureAwait(false); var callUriTemplate = new UriBuilder(this.bot.BotInstanceUri); callUriTemplate.Path = HttpRouteConstants.CallRoutePrefix.Replace("{callLegId}", call.Id); callUriTemplate.Query = this.bot.BotInstanceUri.Query.Trim('?'); var callUri = callUriTemplate.Uri.AbsoluteUri; var values = new Dictionary <string, string> { { "legId", call.Id }, { "scenarioId", call.ScenarioId.ToString() }, { "call", callUri }, { "logs", callUri.Replace("/calls/", "/logs/") }, }; var serializer = new CommsSerializer(pretty: true); var json = serializer.SerializeObject(values); return(this.Ok(json)); } catch (Exception e) { return(this.Exception(e)); } }
/// <summary> /// Joins the call asynchronously. /// </summary> /// <param name="joinCallBody">The join call body.</param> /// <param name="incidentId">Incident Id.</param> /// <returns>The <see cref="ICall"/> that was requested to join.</returns> public async Task <ICall> JoinCallAsync(JoinCallRequestData joinCallBody, string incidentId = "") { // A tracking id for logging purposes. Helps identify this call in logs. var correlationId = string.IsNullOrEmpty(joinCallBody.CorrelationId) ? Guid.NewGuid() : new Guid(joinCallBody.CorrelationId); Microsoft.Graph.MeetingInfo meetingInfo; ChatInfo chatInfo; if (!string.IsNullOrWhiteSpace(joinCallBody.MeetingId)) { // Meeting id is a cloud-video-interop numeric meeting id. var onlineMeeting = await this.OnlineMeetings .GetOnlineMeetingAsync(joinCallBody.TenantId, joinCallBody.MeetingId, correlationId) .ConfigureAwait(false); meetingInfo = new OrganizerMeetingInfo { Organizer = onlineMeeting.Participants.Organizer.Identity, }; meetingInfo.AllowConversationWithoutHost = joinCallBody.AllowConversationWithoutHost; chatInfo = onlineMeeting.ChatInfo; } else { (chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinURL); meetingInfo.AllowConversationWithoutHost = joinCallBody.AllowConversationWithoutHost; } var tenantId = joinCallBody.TenantId ?? (meetingInfo as OrganizerMeetingInfo)?.Organizer.GetPrimaryIdentity()?.GetTenantId(); var mediaToPrefetch = new List <MediaInfo>(); foreach (var m in this.MediaMap) { mediaToPrefetch.Add(m.Value.MediaInfo); } var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, new[] { Modality.Audio }, mediaToPrefetch) { RemoveFromDefaultAudioRoutingGroup = joinCallBody.RemoveFromDefaultRoutingGroup, TenantId = tenantId, CorrelationId = correlationId, }; var statefulCall = await this.Client.Calls().AddAsync(joinParams).ConfigureAwait(false); this.AddCallToHandlers(statefulCall, new IncidentCallContext(IncidentCallType.BotMeeting, incidentId)); this.graphLogger.Info($"Join Call complete: {statefulCall.Id}"); return(statefulCall); }
public async Task <IActionResult> JoinCallAsync([FromBody] JoinCallRequestData joinCallBody) { Validator.NotNull(joinCallBody, nameof(joinCallBody)); try { var call = await this.bot.JoinCallAsync(joinCallBody).ConfigureAwait(false); return(this.Ok(call.Id)); } catch (Exception e) { return(this.Exception(e)); } }
/// <summary> /// Joins the call asynchronously. /// </summary> /// <param name="joinCallBody">The join call body.</param> /// <param name="incidentId">Incident Id.</param> /// <returns>The <see cref="ICall"/> that was requested to join.</returns> public async Task <ICall> JoinCallAsync(JoinCallRequestData joinCallBody, string incidentId = "") { // A tracking id for logging purposes. Helps identify this call in logs. var scenarioId = string.IsNullOrEmpty(joinCallBody.ScenarioId) ? Guid.NewGuid() : new Guid(joinCallBody.ScenarioId); MeetingInfo meetingInfo; ChatInfo chatInfo; if (!string.IsNullOrWhiteSpace(joinCallBody.VideoTeleconferenceId)) { // Meeting id is a cloud-video-interop numeric meeting id. var onlineMeeting = await OnlineMeetings .GetOnlineMeetingAsync(joinCallBody.TenantId, joinCallBody.VideoTeleconferenceId, scenarioId) .ConfigureAwait(false); meetingInfo = new OrganizerMeetingInfo { Organizer = onlineMeeting.Participants.Organizer.Identity, }; chatInfo = onlineMeeting.ChatInfo; } else { (chatInfo, meetingInfo) = JoinInfo.ParseJoinURL(joinCallBody.JoinUrl); } var tenantId = joinCallBody.TenantId ?? (meetingInfo as OrganizerMeetingInfo)?.Organizer.GetPrimaryIdentity()?.GetTenantId(); var mediaToPrefetch = new List <MediaInfo>(); foreach (var m in MediaMap) { mediaToPrefetch.Add(m.Value.MediaInfo); } var joinParams = new JoinMeetingParameters(chatInfo, meetingInfo, new[] { Modality.Audio }, mediaToPrefetch) { TenantId = tenantId, }; var statefulCall = await Client.Calls().AddAsync(joinParams, scenarioId).ConfigureAwait(false); AddCallToHandlers(statefulCall, new IncidentCallContext(IncidentCallType.BotMeeting, incidentId)); graphLogger.Info($"Join Call complete: {statefulCall.Id}"); return(statefulCall); }
public async Task <IActionResult> JoinCallAsync([FromBody] JoinCallRequestData joinCallBody) { Validator.NotNull(joinCallBody, nameof(joinCallBody)); try { var call = await this.bot.JoinCallAsync(joinCallBody).ConfigureAwait(false); var callUriTemplate = new UriBuilder(this.bot.BotInstanceUri); callUriTemplate.Path = HttpRouteConstants.CallRoutePrefix.Replace("{callLegId}", call.Id); callUriTemplate.Query = this.bot.BotInstanceUri.Query.Trim('?'); var callUri = callUriTemplate.Uri.AbsoluteUri; var request = new { Type = "join_call", Call = call, CallUri = callUri }; 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); } } var values = new Dictionary <string, string> { { "legId", call.Id }, { "scenarioId", call.ScenarioId.ToString() }, { "call", callUri }, { "logs", callUri.Replace("/calls/", "/logs/") }, }; var serializer = new CommsSerializer(pretty: true); var json = serializer.SerializeObject(values); return(this.Ok(json)); } catch (Exception e) { return(this.Exception(e)); } }