コード例 #1
0
        /// <summary>
        /// Try to end a particular call.
        /// </summary>
        /// <param name="callLegId">
        /// The call leg id.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task TryDeleteCallAsync(string callLegId)
        {
            CallHandlers.TryGetValue(callLegId, out CallHandler handler);

            if (handler == null)
            {
                return;
            }

            try
            {
                await handler.Call.DeleteAsync().ConfigureAwait(false);

                graphLogger.Info("Delete call finished.");
            }
            catch (Exception ex)
            {
                graphLogger.Error(ex, $"Exception happened when delete the call {callLegId}");

                // in case the call deletion is failed, force remove the call in memory.
                Client.Calls().TryForceRemove(callLegId, out _);

                throw;
            }
        }
コード例 #2
0
 /// <summary>
 /// Updated call handler.
 /// </summary>
 /// <param name="sender">The <see cref="ICallCollection"/> sender.</param>
 /// <param name="args">The <see cref="CollectionEventArgs{ICall}"/> instance containing the event data.</param>
 private void CallsOnUpdated(ICallCollection sender, CollectionEventArgs <ICall> args)
 {
     foreach (var call in args.RemovedResources)
     {
         if (CallHandlers.TryRemove(call.Id, out CallHandler handler))
         {
             handler.Dispose();
         }
     }
 }