Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions Samples/PublicSamples/EchoBot/src/EchoBot/Bot/BotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,18 @@ public async Task<ICall> JoinCallAsync(JoinCallBody joinCallBody)
};
}

if (!this.CallHandlers.TryGetValue(joinParams.ChatInfo.ThreadId, out CallHandler? call))
// For short meeting URL joins, ChatInfo.ThreadId is not known until after the call
// is established, so skip duplicate detection when ThreadId is null or empty.
var threadId = joinParams.ChatInfo.ThreadId;
if (!string.IsNullOrEmpty(threadId) && this.CallHandlers.TryGetValue(threadId, out CallHandler? _))
{
var statefulCall = await this.Client.Calls().AddAsync(joinParams, scenarioId).ConfigureAwait(false);
statefulCall.GraphLogger.Info($"Call creation complete: {statefulCall.Id}");
_logger.LogInformation($"Call creation complete: {statefulCall.Id}");
return statefulCall;
throw new Exception("Call has already been added");
}

throw new Exception("Call has already been added");
var statefulCall = await this.Client.Calls().AddAsync(joinParams, scenarioId).ConfigureAwait(false);
statefulCall.GraphLogger.Info($"Call creation complete: {statefulCall.Id}");
_logger.LogInformation($"Call creation complete: {statefulCall.Id}");
return statefulCall;
}

/// <summary>
Expand Down Expand Up @@ -321,13 +324,13 @@ private void CallsOnUpdated(ICallCollection sender, CollectionEventArgs<ICall> a
foreach (var call in args.AddedResources)
{
var callHandler = new CallHandler(call, _settings, _logger);
var threadId = call.Resource.ChatInfo.ThreadId;
var threadId = call.Resource.ChatInfo?.ThreadId ?? call.Id;
this.CallHandlers[threadId] = callHandler;
}

foreach (var call in args.RemovedResources)
{
var threadId = call.Resource.ChatInfo.ThreadId;
var threadId = call.Resource.ChatInfo?.ThreadId ?? call.Id;
if (this.CallHandlers.TryRemove(threadId, out CallHandler? handler))
{
Task.Run(async () => {
Expand Down