Skip to content

Commit

Permalink
sync with internal repo (#59)
Browse files Browse the repository at this point in the history
## May 2019

- Updated Media library 1.12.1.6-alpha
- Updated Communications libraries 1.1.0-prerelease.452

### Communications 1.1.0-prerelease.452 Changes

The Communications SDKs are now decoupled the `Microsoft.Graph` SDK.  New nugets have been released to as version `1.1.0-prerelease.*` to signal breaking changes due to objects being moved to Microsoft.Graph. 

#### Microsoft.Graph.Communications.Core:

This library no longer contains any Calls contracts... it now references `Microsoft.Graph` 1.14.0 and `Microsoft.Graph.Core` 1.15.0-preview.2 and only contains shared contracts not present in Microsoft.Graph.  It also contains serialization/deserialization helpers and extensions methods to help with the Calling APIs (`IdentitySet.GetGuest`/`IdentitySet.SetGuest`/etc...).  The frameworks have been bumped up to `net461` and `netstandard2.0` so the core SDK can leverage `Microsoft.Graph.Communications.Common`.  Customers using this SDK now have to move to the one containing their specific contracts (below).

#### Microsoft.Graph.Communications.Core.Calls:

Calls wire SDK (contains all the calls and online meetings contracts).  Note that some object names have changed as not to conflict with Microsoft.Graph names.
```
DefaultContainerClient => CallsGraphServiceClient
Notification => CommsNotification
Notifications => CommsNotifications
```

#### Microsoft.Graph.Communications.Calls:

Now references `Microsoft.Graph.Communications.Core.Calls` and `Microsoft.Graph.Communications.Client`.  

Naming conventions of these SDKs were changed as they are namespaced and do not need the Call prefix:
```
ICallParticipantCollection => IParticipantCollection
ICallParticipant => IParticipant
```

### Misc changes
- Contract sync with latest Beta Calling contracts.
- Updated to `Microsoft.Graph.Core` 1.15.0-preview.2 SDK to resolve inconsistencies between `ServiceException` types.
- Updated to `Microsoft.Graph` 1.14.0 SDK.
- Updated to `Microsoft.Skype.Bots.Media` 1.12.1.6-alpha SDK.
- Added `promptsQueued` callback to be notified when a prompt has been queued, and the next one can be added.  This is only valid for scenarios where bot developers queue a single prompt at a time.  If 1P developers pass in multiple prompts, order is guaranteed.
- Added proper cleanup of resources when ESDK resources get garbage collected.  This fixes a memory leak where internal notification queues were not getting removed when resources were GCd without `Dispose()` being called.
- First stages of HA/DR support.  SDK supports passing in an `ICache` interface that notifies the bot developer whenever internal state has changed.  It is also used to recover state when calling `ICommunicationsClient.RehydrateAsync`.  An implementation of re-hydration from PMA is built in by default, but it does not support AudioRoutingGroupentities.
- Deprecated support for Chain-Id/Correlation-Id in ESDK.  It is replaced with Scenario-Id, which can be set by the client as a kind of "telemetry identifier" to correlate any calls together.
  • Loading branch information
ksikorsk authored May 6, 2019
1 parent 48afbc9 commit aa91682
Show file tree
Hide file tree
Showing 655 changed files with 136,113 additions and 38,822 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ Example appsettings.json
"Bot": {
"AppId": "00000000-0000-0000-0000-000000000000", --> The MicrosoftAppId/BotId from above
"AppSecret": "__placeholder__", --> The MicrosoftAppPassword from above
"PlaceCallEndpointUrl": "https://graph.microsoft.com/testcomms", --> This is the Microosft Graph entry point. Please keep the default value without any changes.
"AuthTokenAudience": "https://graph.microsoft.com", --> This is the Microosft Graph entry point. Please keep the default value without any changes.
"PlaceCallEndpointUrl": "https://graph.microsoft.com/beta", --> This is the Microsoft Graph entry point. Please keep the default value without any changes.
"BotBaseUrl": "http://contosobot.azurewebsites.net/" --> The BotBaseUrl is where the App Service is published
}
```
Expand Down Expand Up @@ -81,19 +80,18 @@ Once your App Service is published and running, you will need to send a POST req

```json
{
"name": "<name-of-incident>", --> can be any string value
"time": "<start-time-of-the-incident>", --> can be any string value
"name": "<name-of-incident>", --> can be any string value
"time": "<start-time-of-the-incident>", --> must be valid C# DateTime string

"tenantId": "{TenantId}", --> TenantID of the users your bot will be calling
"objectIds": [
"{UserObjectId-1}",
"{UserObjectId-2}"
],

"meetingId": "{MeetingId}",
"joinURL": "https://teams.microsoft.com/l/meetup-join/...",
"removeFromDefaultRoutingGroup": true,
"allowConversationWithoutHost": true
"tenantId": "{TenantId}", --> TenantID of the users your bot will be calling
"objectIds": [
"{UserObjectId-1}",
"{UserObjectId-2}"
],

"joinURL": "https://teams.microsoft.com/l/meetup-join/...",
"removeFromDefaultRoutingGroup": true,
"allowConversationWithoutHost": true
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IncidentBot", "IncidentBot\IncidentBot.csproj", "{FA70E97D-7018-4B08-A9D0-ABA9967AD7DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Common", "..\Common\Sample.Common\Sample.Common.csproj", "{3268E59C-90DC-4D7B-97EA-A1DBB2716DF3}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Common", "..\..\Common\Sample.Common\Sample.Common.csproj", "{3268E59C-90DC-4D7B-97EA-A1DBB2716DF3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public IEnumerable<string> GetCallbackLogs(int maxCount)
public async Task<ICall> RaiseIncidentAsync(IncidentRequestData incidentRequestData)
{
// A tracking id for logging purposes. Helps identify this call in logs.
var correlationId = string.IsNullOrEmpty(incidentRequestData.CorrelationId) ? Guid.NewGuid() : new Guid(incidentRequestData.CorrelationId);
var scenarioId = string.IsNullOrEmpty(incidentRequestData.ScenarioId) ? Guid.NewGuid() : new Guid(incidentRequestData.ScenarioId);

string incidentId = Guid.NewGuid().ToString();

Expand All @@ -209,7 +209,7 @@ public async Task<ICall> RaiseIncidentAsync(IncidentRequestData incidentRequestD
incidentRequestData.TenantId,
objectId,
"Application".Equals(incidentRequestData.ResponderType, StringComparison.OrdinalIgnoreCase));
var responderCall = await this.MakeCallAsync(makeCallRequestData, correlationId).ConfigureAwait(false);
var responderCall = await this.MakeCallAsync(makeCallRequestData, scenarioId).ConfigureAwait(false);
this.AddCallToHandlers(responderCall, new IncidentCallContext(IncidentCallType.ResponderNotification, incidentId));
}

Expand All @@ -225,15 +225,15 @@ public async Task<ICall> RaiseIncidentAsync(IncidentRequestData incidentRequestD
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);
var scenarioId = string.IsNullOrEmpty(joinCallBody.ScenarioId) ? Guid.NewGuid() : new Guid(joinCallBody.ScenarioId);

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)
.GetOnlineMeetingAsync(joinCallBody.TenantId, joinCallBody.MeetingId, scenarioId)
.ConfigureAwait(false);

meetingInfo = new OrganizerMeetingInfo { Organizer = onlineMeeting.Participants.Organizer.Identity, };
Expand All @@ -259,10 +259,9 @@ public async Task<ICall> JoinCallAsync(JoinCallRequestData joinCallBody, string
{
RemoveFromDefaultAudioRoutingGroup = joinCallBody.RemoveFromDefaultRoutingGroup,
TenantId = tenantId,
CorrelationId = correlationId,
};

var statefulCall = await this.Client.Calls().AddAsync(joinParams).ConfigureAwait(false);
var statefulCall = await this.Client.Calls().AddAsync(joinParams, scenarioId).ConfigureAwait(false);

this.AddCallToHandlers(statefulCall, new IncidentCallContext(IncidentCallType.BotMeeting, incidentId));

Expand All @@ -275,9 +274,9 @@ public async Task<ICall> JoinCallAsync(JoinCallRequestData joinCallBody, string
/// Makes outgoing call asynchronously.
/// </summary>
/// <param name="makeCallBody">The outgoing call request body.</param>
/// <param name="correlationId">Correlation id.</param>
/// <param name="scenarioId">The scenario identifier.</param>
/// <returns>The <see cref="Task"/>.</returns>
public async Task<ICall> MakeCallAsync(MakeCallRequestData makeCallBody, Guid correlationId)
public async Task<ICall> MakeCallAsync(MakeCallRequestData makeCallBody, Guid scenarioId)
{
if (makeCallBody == null)
{
Expand Down Expand Up @@ -331,10 +330,9 @@ public async Task<ICall> MakeCallAsync(MakeCallRequestData makeCallBody, Guid co
MediaConfig = new ServiceHostedMediaConfig { PreFetchMedia = mediaToPrefetch },
RequestedModalities = new List<Modality> { Modality.Audio },
TenantId = makeCallBody.TenantId,
CorrelationId = correlationId,
};

var statefulCall = await this.Client.Calls().AddAsync(call).ConfigureAwait(false);
var statefulCall = await this.Client.Calls().AddAsync(call, scenarioId: scenarioId).ConfigureAwait(false);

this.graphLogger.Info($"Call creation complete: {statefulCall.Id}");

Expand Down Expand Up @@ -422,23 +420,6 @@ public async Task DeleteAudioRoutingGroupAsync(string callLegId, RoutingMode rou
await this.Client.Calls()[callLegId].AudioRoutingGroups[routingMode.ToString()].DeleteAsync().ConfigureAwait(false);
}

/// <summary>
/// Get the logs for a particular call.
/// </summary>
/// <param name="callLegId">
/// The call Leg Id.
/// </param>
/// <param name="limit">
/// The limit.
/// </param>
/// <returns>
/// The collection of logs.
/// </returns>
internal IEnumerable<string> GetLogsByCallLegId(string callLegId, int limit)
{
return this.GetHandlerOrThrow(callLegId).OutcomesLogMostRecentFirst.Take(limit);
}

/// <summary>
/// Incoming call handler.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
namespace Sample.IncidentBot.Bot
{
using System;
using System.Collections.Generic;
using Microsoft.Graph;
using Microsoft.Graph.Communications.Calls;
using Microsoft.Graph.Communications.Common.Telemetry;
using Microsoft.Graph.Communications.Core.Serialization;
using Microsoft.Graph.Communications.Resources;

/// <summary>
Expand All @@ -28,12 +26,9 @@ public CallHandler(Bot bot, ICall call)
this.Bot = bot;
this.Call = call;

// Use the call GraphLogger so we carry the call/correlation context in each log record.
// Use the call GraphLogger so we carry the call/scenario context in each log record.
this.Logger = call.GraphLogger.CreateShim(component: this.GetType().Name);

var outcome = Serializer.SerializeObject(call.Resource);
this.OutcomesLogMostRecentFirst.AddFirst("Call Created:\n" + outcome);

this.Call.OnUpdated += this.OnCallUpdated;
this.Call.Participants.OnUpdated += this.OnParticipantsUpdated;
}
Expand All @@ -43,14 +38,6 @@ public CallHandler(Bot bot, ICall call)
/// </summary>
public ICall Call { get; }

/// <summary>
/// Gets the outcomes log - maintained for easy checking of async server responses.
/// </summary>
/// <value>
/// The outcomes log.
/// </value>
public LinkedList<string> OutcomesLogMostRecentFirst { get; } = new LinkedList<string>();

/// <summary>
/// Gets the bot.
/// </summary>
Expand All @@ -61,11 +48,6 @@ public CallHandler(Bot bot, ICall call)
/// </summary>
protected IGraphLogger Logger { get; }

/// <summary>
/// Gets the serializer.
/// </summary>
private static Serializer Serializer { get; } = new Serializer(pretty: true);

/// <inheritdoc />
public void Dispose()
{
Expand Down Expand Up @@ -93,7 +75,7 @@ protected virtual void CallOnUpdated(ICall sender, ResourceEventArgs<Call> args)
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The arguments.</param>
protected virtual void ParticipantsOnUpdated(ICallParticipantCollection sender, CollectionEventArgs<ICallParticipant> args)
protected virtual void ParticipantsOnUpdated(IParticipantCollection sender, CollectionEventArgs<IParticipant> args)
{
// do nothing in base class.
}
Expand All @@ -103,7 +85,7 @@ protected virtual void ParticipantsOnUpdated(ICallParticipantCollection sender,
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The arguments.</param>
protected virtual void ParticipantOnUpdated(ICallParticipant sender, ResourceEventArgs<Participant> args)
protected virtual void ParticipantOnUpdated(IParticipant sender, ResourceEventArgs<Participant> args)
{
// do nothing in base class.
}
Expand All @@ -115,9 +97,6 @@ protected virtual void ParticipantOnUpdated(ICallParticipant sender, ResourceEve
/// <param name="args">The event arguments.</param>
private void OnCallUpdated(ICall sender, ResourceEventArgs<Call> args)
{
var outcome = Serializer.SerializeObject(sender.Resource);
this.OutcomesLogMostRecentFirst.AddFirst("Call Updated:\n" + outcome);

this.CallOnUpdated(sender, args);
}

Expand All @@ -126,11 +105,8 @@ private void OnCallUpdated(ICall sender, ResourceEventArgs<Call> args)
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The arguments.</param>
private void OnParticipantUpdated(ICallParticipant sender, ResourceEventArgs<Participant> args)
private void OnParticipantUpdated(IParticipant sender, ResourceEventArgs<Participant> args)
{
var outcome = Serializer.SerializeObject(sender.Resource);
this.OutcomesLogMostRecentFirst.AddFirst("Participant Updated:\n" + outcome);

this.ParticipantOnUpdated(sender, args);
}

Expand All @@ -139,21 +115,15 @@ private void OnParticipantUpdated(ICallParticipant sender, ResourceEventArgs<Par
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="args">The arguments.</param>
private void OnParticipantsUpdated(ICallParticipantCollection sender, CollectionEventArgs<ICallParticipant> args)
private void OnParticipantsUpdated(IParticipantCollection sender, CollectionEventArgs<IParticipant> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public MeetingCallHandler(Bot bot, ICall call, IncidentStatusData statusData)
{
this.statusData = statusData;

this.statusData?.UpdateBotMeetingCallId(call.Id, call.CorrelationId);
this.statusData?.UpdateBotMeetingCallId(call.Id, call.ScenarioId);
}

/// <inheritdoc/>
Expand All @@ -40,7 +40,7 @@ protected override void CallOnUpdated(ICall sender, ResourceEventArgs<Call> args
}

/// <inheritdoc/>
protected override void ParticipantsOnUpdated(ICallParticipantCollection sender, CollectionEventArgs<ICallParticipant> args)
protected override void ParticipantsOnUpdated(IParticipantCollection sender, CollectionEventArgs<IParticipant> args)
{
foreach (var participant in args.AddedResources)
{
Expand All @@ -52,7 +52,7 @@ protected override void ParticipantsOnUpdated(ICallParticipantCollection sender,
continue;
}

this.statusData?.UpdateResponderMeetingCallId(responderId, this.Call.Id, this.Call.CorrelationId);
this.statusData?.UpdateResponderMeetingCallId(responderId, this.Call.Id, this.Call.ScenarioId);

this.statusData?.UpdateResponderMeetingStatus(responderId, IncidentResponderMeetingStatus.Added);

Expand All @@ -79,7 +79,7 @@ protected override void ParticipantsOnUpdated(ICallParticipantCollection sender,
}

/// <inheritdoc/>
protected override void ParticipantOnUpdated(ICallParticipant sender, ResourceEventArgs<Participant> args)
protected override void ParticipantOnUpdated(IParticipant sender, ResourceEventArgs<Participant> args)
{
// do nothing.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ResponderCallHandler(Bot bot, ICall call, string responderId, IncidentSta
this.responderId = responderId;
this.statusData = statusData;

this.statusData?.UpdateResponderNotificationCallId(this.responderId, call.Id, call.CorrelationId);
this.statusData?.UpdateResponderNotificationCallId(this.responderId, call.Id, call.ScenarioId);
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ public async Task<IEnumerable<IncidentStatusData>> GetRecentIncidentsAsync(int m
return await Task.FromResult(this.bot.IncidentStatusManager.GetRecentIncidents(maxCount)).ConfigureAwait(false);
}

/// <summary>
/// Get the responder status.
/// </summary>
/// <param name="callId">The call id.</param>
/// <param name="maxCount">The maximum count of log lines.</param>
/// <returns>The logs.</returns>
[HttpGet]
[Route("/log/calls/{callId}")]
public async Task<IEnumerable<string>> GetCallDetailsAsync(string callId, int maxCount = 1000)
{
Validator.IsTrue(Guid.TryParse(callId, out Guid result), nameof(callId), "call id must be a valid guid.");

return await Task.FromResult(this.bot.GetLogsByCallLegId(callId, maxCount)).ConfigureAwait(false);
}

/// <summary>
/// Get the service logs.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public ActionResult<List<Dictionary<string, string>>> OnGetCalls()
var values = new Dictionary<string, string>
{
{ "legId", call.Id },
{ "correlationId", call.CorrelationId.ToString() },
{ "scenarioId", call.ScenarioId.ToString() },
};
calls.Add(values);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Sample.IncidentBot.Http
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.WebApiCompatShim;
using Microsoft.Graph;
using Microsoft.Graph.Communications.Client;
using Microsoft.Graph.Communications.Common.Telemetry;
using Sample.IncidentBot.Bot;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public class JoinCallRequestData
public string TenantId { get; set; }

/// <summary>
/// Gets or sets the correlation id.
/// Gets or sets the scenario id.
/// </summary>
public string CorrelationId { get; set; }
public string ScenarioId { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to remove the bot from default routing group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Microsoft.Extensions.Primitives;
using Microsoft.Graph.Communications.Core.Exceptions;
using Microsoft.Graph;

/// <summary>
/// The controller exceptions.
Expand Down
Loading

0 comments on commit aa91682

Please sign in to comment.