Ejemplo n.º 1
0
        /// Join the call using server call id.
        /// <param name="serverCallId"> The server call id. </param>
        /// <param name="source"> The source identity. </param>
        /// <param name="callOptions"> The call Options. </param>
        /// <param name="cancellationToken"> The cancellation token. </param>
        /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="serverCallId"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="callOptions"/> is null.</exception>
        public virtual Response <CallConnection> JoinCall(string serverCallId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default)
        {
            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(JoinCall)}");
            scope.Start();
            try
            {
                Argument.AssertNotNull(source, nameof(source));
                Argument.AssertNotNull(callOptions, nameof(callOptions));

                var joinCallResponse = ServerCallRestClient.JoinCall(
                    serverCallId: serverCallId,
                    source: CommunicationIdentifierSerializer.Serialize(source),
                    callbackUri: callOptions.CallbackUri?.AbsoluteUri,
                    requestedMediaTypes: callOptions.RequestedMediaTypes,
                    requestedCallEvents: callOptions.RequestedCallEvents,
                    subject: null,
                    cancellationToken: cancellationToken
                    );

                return(Response.FromValue(
                           new CallConnection(joinCallResponse.Value.CallConnectionId, CallConnectionRestClient, _clientDiagnostics),
                           joinCallResponse.GetRawResponse()));
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary> Add a participant to the call. </summary>
        /// <param name="callLegId"> The call leg id. </param>
        /// <param name="participant"> The identity of participant to be added to the call. </param>
        /// <param name="alternateCallerId">The phone number to use when adding a pstn participant.</param>
        /// <param name="operationContext">The operation context. </param>
        /// <param name="cancellationToken"> The cancellation token. </param>
        /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
        /// <exception cref="ArgumentNullException"> <paramref name="participant"/> is null. </exception>
        public virtual Response AddParticipant(string callLegId, CommunicationIdentifier participant, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default)
        {
            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(AddParticipant)}");
            scope.Start();
            try
            {
                Argument.AssertNotNull(participant, nameof(participant));
                Argument.AssertNotNullOrEmpty(alternateCallerId, nameof(alternateCallerId));

                return(RestClient.InviteParticipants(
                           callId: callLegId,
                           participants: new List <CommunicationIdentifierModel>()
                {
                    CommunicationIdentifierSerializer.Serialize(participant)
                },
                           alternateCallerId: new PhoneNumberIdentifierModel(alternateCallerId),
                           operationContext: operationContext,
                           callbackUri: null,
                           cancellationToken: cancellationToken
                           ));
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
        }
Ejemplo n.º 3
0
        /// Create an outgoing call from source to target identities.
        /// <param name="source"> The source identity </param>
        /// <param name="targets"> The target identities. </param>
        /// <param name="options"> The call options. </param>
        /// <param name="cancellationToken"> The cancellation token. </param>
        /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="targets"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="options"/> is null.</exception>
        public virtual Response <CallConnection> CreateCallConnection(CommunicationIdentifier source, IEnumerable <CommunicationIdentifier> targets, CreateCallOptions options, CancellationToken cancellationToken = default)
        {
            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallingServerClient)}.{nameof(CreateCallConnection)}");
            scope.Start();
            try
            {
                Argument.AssertNotNull(source, nameof(source));
                Argument.AssertNotNullOrEmpty(targets, nameof(targets));
                Argument.AssertNotNull(options, nameof(options));

                var createCallResponse = CallConnectionRestClient.CreateCall(
                    source: CommunicationIdentifierSerializer.Serialize(source),
                    targets: targets.Select(t => CommunicationIdentifierSerializer.Serialize(t)),
                    callbackUri: options.CallbackUri?.AbsoluteUri,
                    requestedMediaTypes: options.RequestedMediaTypes,
                    requestedCallEvents: options.RequestedCallEvents,
                    alternateCallerId: options.AlternateCallerId == null ? null : new PhoneNumberIdentifierModel(options.AlternateCallerId.PhoneNumber),
                    subject: options.Subject,
                    cancellationToken: cancellationToken
                    );

                return(Response.FromValue(
                           new CallConnection(createCallResponse.Value.CallConnectionId, CallConnectionRestClient, _clientDiagnostics),
                           createCallResponse.GetRawResponse()));
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
        }
Ejemplo n.º 4
0
        /// Join the call using conversation id.
        /// <param name="conversationId"> The conversation id that can be a group id or a encoded conversation url retrieve from client. </param>
        /// <param name="source"> The source identity. </param>
        /// <param name="callOptions"> The call Options. </param>
        /// <param name="cancellationToken"> The cancellation token. </param>
        /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="conversationId"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="callOptions"/> is null.</exception>
        public virtual Response <JoinCallResponse> JoinCall(string conversationId, CommunicationIdentifier source, JoinCallOptions callOptions, CancellationToken cancellationToken = default)
        {
            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(JoinCall)}");
            scope.Start();
            try
            {
                Argument.AssertNotNull(source, nameof(source));
                Argument.AssertNotNull(callOptions, nameof(callOptions));

                return(RestClient.JoinCall(
                           conversationId: conversationId,
                           source: CommunicationIdentifierSerializer.Serialize(source),
                           callbackUri: callOptions.CallbackUri?.AbsoluteUri,
                           requestedModalities: callOptions.RequestedModalities,
                           requestedCallEvents: callOptions.RequestedCallEvents,
                           subject: null,
                           cancellationToken: cancellationToken
                           ));
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
        }
Ejemplo n.º 5
0
        /// Create an outgoing call from source to target identities.
        /// <param name="source"> The source identity </param>
        /// <param name="targets"> The target identities. </param>
        /// <param name="options"> The call options. </param>
        /// <param name="cancellationToken"> The cancellation token. </param>
        /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="targets"/> is null.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="options"/> is null.</exception>
        public virtual Response <CreateCallResponse> CreateCall(CommunicationIdentifier source, IEnumerable <CommunicationIdentifier> targets, CreateCallOptions options, CancellationToken cancellationToken = default)
        {
            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallClient)}.{nameof(CreateCall)}");
            scope.Start();
            try
            {
                Argument.AssertNotNull(source, nameof(source));
                Argument.AssertNotNullOrEmpty(targets, nameof(targets));
                Argument.AssertNotNull(options, nameof(options));

                var sourceAlternateIdentity = options.AlternateCallerId == null ? null : new PhoneNumberIdentifierModel(options.AlternateCallerId.PhoneNumber);

                return(RestClient.CreateCall(
                           targets: targets.Select(t => CommunicationIdentifierSerializer.Serialize(t)),
                           source: CommunicationIdentifierSerializer.Serialize(source),
                           callbackUri: options.CallbackUri?.AbsoluteUri,
                           requestedModalities: options.RequestedModalities,
                           requestedCallEvents: options.RequestedCallEvents,
                           sourceAlternateIdentity: sourceAlternateIdentity,
                           subject: options.Subject,
                           cancellationToken: cancellationToken
                           ));
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
        }
Ejemplo n.º 6
0
        public async Task CreateCallAsyncOverload_Passes(CommunicationIdentifier expectedSource, IEnumerable <CommunicationIdentifier> expectedTargets, CreateCallOptions expectedOptions)
        {
            Mock <CallClient> mockClient = new Mock <CallClient>()
            {
                CallBase = true
            };
            Response <CreateCallResponse>?expectedResponse  = default;
            CancellationToken             cancellationToken = new CancellationTokenSource().Token;
            var callExpression = BuildExpression(x => x.CreateCallAsync(It.IsAny <CommunicationIdentifier>(), It.IsAny <IEnumerable <CommunicationIdentifier> >(), It.IsAny <CreateCallOptions>(), It.IsAny <CancellationToken>()));

            mockClient
            .Setup(callExpression)
            .ReturnsAsync((CommunicationIdentifier source, IEnumerable <CommunicationIdentifier> targets, CreateCallOptions options, CancellationToken token) =>
            {
                Assert.AreEqual(expectedSource, source);
                Assert.AreEqual(expectedTargets, targets);
                Assert.AreEqual(expectedOptions, options);
                Assert.AreEqual(cancellationToken, token);
                return(expectedResponse = new Mock <Response <CreateCallResponse> >().Object);
            });

            Response <CreateCallResponse> actualResponse = await mockClient.Object.CreateCallAsync(expectedSource, expectedTargets, expectedOptions, cancellationToken);

            mockClient.Verify(callExpression, Times.Once());
            Assert.AreEqual(expectedResponse, actualResponse);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Add participant to the call.
        /// </summary>
        /// <param name="conversationId"> The conversation id that can be a group id or a encoded conversation url retrieve from client. </param>
        /// <param name="participant"> The identity of participant to be added to the call. </param>
        /// <param name="callbackUri">The callback uri to receive the notification.</param>
        /// <param name="alternateCallerId">The phone number to use when adding a pstn participant.</param>
        /// <param name="operationContext">The operation context.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        public virtual Response AddParticipant(string conversationId, CommunicationIdentifier participant, Uri callbackUri, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default)
        {
            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ConversationClient)}.{nameof(AddParticipant)}");
            scope.Start();
            try
            {
                Argument.AssertNotNull(participant, nameof(participant));

                var participantsInternal = new List <CommunicationIdentifierModel> {
                    CommunicationIdentifierSerializer.Serialize(participant)
                };
                var alternateCallerIdInternal = string.IsNullOrEmpty(alternateCallerId) ? null : new PhoneNumberIdentifierModel(alternateCallerId);
                return(RestClient.InviteParticipants(
                           conversationId: conversationId,
                           participants: participantsInternal,
                           alternateCallerId: alternateCallerIdInternal,
                           callbackUri: callbackUri?.AbsoluteUri,
                           operationContext: operationContext,
                           cancellationToken: cancellationToken
                           ));
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
        }
        public void JoinCallAsync_Returns404NotFound(string serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions)
        {
            CallingServerClient callingServerClient = CreateMockCallingServerClient(404);

            RequestFailedException?ex = Assert.ThrowsAsync <RequestFailedException>(async() => await callingServerClient.JoinCallAsync(serverCallId, source, joinCallOptions).ConfigureAwait(false));

            Assert.NotNull(ex);
            Assert.AreEqual(ex?.Status, 404);
        }
        public void JoinCall_Returns202Accepted(string serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions)
        {
            CallingServerClient callingServerClient = CreateMockCallingServerClient(202, CreateOrJoinCallPayload);

            var response = callingServerClient.JoinCall(serverCallId, source, joinCallOptions);

            Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status);
            Assert.AreEqual("cad9df7b-f3ac-4c53-96f7-c76e7437b3c1", response.Value.CallConnectionId);
        }
        public void CreateCall_Returns404NotFound(CommunicationIdentifier source, IEnumerable <CommunicationIdentifier> targets, CreateCallOptions createCallOptions)
        {
            CallingServerClient callingServerClient = CreateMockCallingServerClient(404);

            RequestFailedException?ex = Assert.Throws <RequestFailedException>(() => callingServerClient.CreateCallConnection(source, targets, createCallOptions));

            Assert.NotNull(ex);
            Assert.AreEqual(ex?.Status, 404);
        }
        public void CreateCall_Returns201Created(CommunicationIdentifier source, IEnumerable <CommunicationIdentifier> targets, CreateCallOptions createCallOptions)
        {
            CallingServerClient callingServerClient = CreateMockCallingServerClient(201, CreateOrJoinCallPayload);

            var response = callingServerClient.CreateCallConnection(source, targets, createCallOptions);

            Assert.AreEqual((int)HttpStatusCode.Created, response.GetRawResponse().Status);
            Assert.AreEqual("cad9df7b-f3ac-4c53-96f7-c76e7437b3c1", response.Value.CallConnectionId);
        }
        public void AddParticipants_Failed(CommunicationIdentifier participant, string alternateCallerId, string operationContext)
        {
            var callConnection = CreateMockCallConnection(404);

            RequestFailedException?ex = Assert.Throws <RequestFailedException>(() => callConnection.AddParticipant(participant, alternateCallerId, operationContext));

            Assert.NotNull(ex);
            Assert.AreEqual(ex?.Status, 404);
        }
        public void AddParticipantsAsync_Failed(CommunicationIdentifier participant, string alternateCallerId, string operationContext)
        {
            var callConnection = CreateMockCallConnection(404);

            RequestFailedException?ex = Assert.ThrowsAsync <RequestFailedException>(async() => await callConnection.AddParticipantAsync(participant, alternateCallerId, operationContext).ConfigureAwait(false));

            Assert.NotNull(ex);
            Assert.AreEqual(ex?.Status, 404);
        }
        public void AddParticipants_Passes(CommunicationIdentifier participant, string alternateCallerId, string operationContext)
        {
            var callConnection = CreateMockCallConnection(202, AddParticipantResultPayload);

            var response = callConnection.AddParticipant(participant, alternateCallerId, operationContext);

            Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status);
            Assert.AreEqual("dummyparticipantid", response.Value.ParticipantId);
        }
        public void JoinCall_Returns404NotFound(string serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions)
        {
            CallingServerClient callingServerClient = CreateMockCallingServerClient(404);

            RequestFailedException?ex = Assert.Throws <RequestFailedException>(() => callingServerClient.JoinCall(serverCallId, source, joinCallOptions));

            Assert.NotNull(ex);
            Assert.AreEqual(ex?.Status, 404);
        }
Ejemplo n.º 16
0
        public void AddParticipants_Returns404NotFound(CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext)
        {
            var serverCall = CreateMockServerCall(404);

            RequestFailedException?ex = Assert.Throws <RequestFailedException>(() => serverCall.AddParticipant(participant, callBack, alternateCallerId, operationContext));

            Assert.NotNull(ex);
            Assert.AreEqual(ex?.Status, 404);
        }
Ejemplo n.º 17
0
        public void AddParticipants_Return202Accepted(CommunicationIdentifier participant, Uri callBack, string alternateCallerId, string operationContext)
        {
            var serverCall = CreateMockServerCall(202, AddParticipantResultPayload);

            var response = serverCall.AddParticipant(participant, callBack, alternateCallerId, operationContext);

            Assert.AreEqual((int)HttpStatusCode.Accepted, response.GetRawResponse().Status);
            Assert.AreEqual("dummyparticipantid", response.Value.ParticipantId);
        }
 public void CallPhone(string phoneNumber)
 {
     var acsNumber = new PhoneNumberIdentifier(phoneNumber, phoneNumber);
     var receivers = new CommunicationIdentifier[] { acsNumber };
     var callOptions = new ACSStartCallOptions
     {
         AudioOptions = new ACSAudioOptions()
     };
     _call = _callAgent.StartCall(receivers, callOptions);
 }
        public void CallEchoService()
        {
            var callOptions = new ACSStartCallOptions();
            var camera = _deviceManager.Cameras.First(c => c.CameraFacing == ACSCameraFacing.Front);
            callOptions.AudioOptions = new ACSAudioOptions();

            //callOptions.AudioOptions.Muted = true;
            var localVideoStream = new ACSLocalVideoStream(camera);
            callOptions.VideoOptions = new ACSVideoOptions(localVideoStream);

            var receivers = new CommunicationIdentifier[] { new CommunicationUserIdentifier("8:echo123") };

            _callAgent.StartCall(receivers, callOptions);
        }
        public void CallEchoService()
        {
            var callOptions = new StartCallOptions();
            var camera      = _deviceManager.CameraList.First(c => c.CameraFacing == CameraFacing.Front);

            callOptions.AudioOptions = new AudioOptions();

            //callOptions.AudioOptions.Muted = true;
            var localVideoStream = new LocalVideoStream(camera, MainActivity.Instance);

            callOptions.VideoOptions = new VideoOptions(localVideoStream);

            var receivers = new CommunicationIdentifier[] { new CommunicationUserIdentifier("8:echo123") };

            _call = _callAgent.Call(MainActivity.Instance, receivers, callOptions);
        }
Ejemplo n.º 21
0
        public void CallEchoService()
        {
            var callOptions = new StartCallOptions();
            var camera      = _deviceManager.Cameras.First(c => c.CameraFacing == CameraFacing.Front);

            callOptions.SetAudioOptions(new AudioOptions());

            //callOptions.AudioOptions.Muted = true;
            var localVideoStream = new LocalVideoStream(camera, MainActivity.Instance);

            callOptions.SetVideoOptions(new VideoOptions(new LocalVideoStream[] { localVideoStream }));

            var receivers = new CommunicationIdentifier[] { new CommunicationUserIdentifier("8:echo123") };
            // TODO:
            //_callAgent.StartCall();
            //var locator = new GroupCallLocator()
            //_call = _callAgent. Join(MainActivity.Instance, receivers, callOptions);
        }
Ejemplo n.º 22
0
 /// <summary> Remove a member from a thread .</summary>
 /// <param name="identifier"><see cref="CommunicationIdentifier" /> to be removed from the chat thread participants.</param>
 /// <param name="cancellationToken"> The cancellation token to use. </param>
 /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
 public virtual Response RemoveParticipant(CommunicationIdentifier identifier, CancellationToken cancellationToken = default)
 {
     using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ChatThreadClient)}.{nameof(RemoveParticipant)}");
     scope.Start();
     try
     {
         CommunicationIdentifierModel communicationIdentifierModel = CommunicationIdentifierSerializer.Serialize(identifier);
         return(_chatThreadRestClient.RemoveChatParticipant(Id, communicationIdentifierModel.RawId,
                                                            communicationIdentifierModel.CommunicationUser,
                                                            communicationIdentifierModel.PhoneNumber,
                                                            communicationIdentifierModel.MicrosoftTeamsUser,
                                                            cancellationToken));
     }
     catch (Exception ex)
     {
         scope.Failed(ex);
         throw;
     }
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Add participant to the call.
        /// </summary>
        /// <param name="participant"> The identity of participant to be added to the call. </param>
        /// <param name="callbackUri">The callback uri to receive the notification.</param>
        /// <param name="alternateCallerId">The phone number to use when adding a pstn participant.</param>
        /// <param name="operationContext">The operation context.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        public virtual Response <AddParticipantResult> AddParticipant(CommunicationIdentifier participant, Uri callbackUri, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default)
        {
            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ServerCall)}.{nameof(AddParticipant)}");
            scope.Start();
            try
            {
                Argument.AssertNotNull(participant, nameof(participant));

                return(RestClient.AddParticipant(
                           serverCallId: ServerCallId,
                           participant: CommunicationIdentifierSerializer.Serialize(participant),
                           alternateCallerId: string.IsNullOrEmpty(alternateCallerId) ? null : new PhoneNumberIdentifierModel(alternateCallerId),
                           callbackUri: callbackUri?.AbsoluteUri,
                           operationContext: operationContext,
                           cancellationToken: cancellationToken
                           ));
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
        }
Ejemplo n.º 24
0
 internal ChatMessageReadReceipt(CommunicationIdentifier sender, string chatMessageId, DateTimeOffset readOn)
 {
     Sender        = sender;
     ChatMessageId = chatMessageId;
     ReadOn        = readOn;
 }
 /// <summary> Initializes a new instance of CommunicationParticipant. </summary>
 /// <param name="identifier"> The communication identifier. </param>
 /// <param name="participantId"> Participant Id. </param>
 /// <param name="isMuted"> Is participant muted. </param>
 public CommunicationParticipant(CommunicationIdentifier identifier, string participantId, bool?isMuted)
 {
     Identifier    = identifier;
     ParticipantId = participantId;
     IsMuted       = isMuted;
 }
Ejemplo n.º 26
0
 /// <summary>
 ///  A member of the chat thread.
 /// </summary>
 /// <param name="identifier">Instance of <see cref="CommunicationIdentifier"/>.</param>
 public ChatParticipant(CommunicationIdentifier identifier)
 {
     User = identifier;
 }
Ejemplo n.º 27
0
        public async Task InviteParticipantsAsyncOverload_Passes(string expectedCallLegId, CommunicationIdentifier expectedParticipant, string expectedAlternateCallerId, string expectedOperationContext)
        {
            Mock <CallClient> mockClient = new Mock <CallClient>()
            {
                CallBase = true
            };
            Response?         expectedResponse  = default;
            CancellationToken cancellationToken = new CancellationTokenSource().Token;
            var callExpression = BuildExpression(x => x.AddParticipantAsync(It.IsAny <string>(), It.IsAny <CommunicationIdentifier>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>()));

            mockClient
            .Setup(callExpression)
            .ReturnsAsync((string callLegId, CommunicationIdentifier participants, string operationContext, string alternateCallerId, CancellationToken token) =>
            {
                Assert.AreEqual(expectedCallLegId, callLegId);
                Assert.AreEqual(expectedParticipant, participants);
                Assert.AreEqual(expectedOperationContext, operationContext);
                Assert.AreEqual(expectedAlternateCallerId, alternateCallerId);
                Assert.AreEqual(cancellationToken, token);
                return(expectedResponse = new Mock <Response>().Object);
            });

            Response actualResponse = await mockClient.Object.AddParticipantAsync(expectedCallLegId, expectedParticipant, expectedOperationContext, expectedAlternateCallerId, cancellationToken);

            mockClient.Verify(callExpression, Times.Once());
            Assert.AreEqual(expectedResponse, actualResponse);
        }
Ejemplo n.º 28
0
 /// <summary> Initializes a new instance of CallParticipant. </summary>
 /// <param name="identifier"> The communication identifier. </param>
 /// <param name="participantId"> Participant Id. </param>
 /// <param name="isMuted"> Is participant muted. </param>
 internal CallParticipant(CommunicationIdentifier identifier, string participantId, bool isMuted)
 {
     Identifier    = identifier;
     ParticipantId = participantId;
     IsMuted       = isMuted;
 }
 public static ChatMessageReadReceipt ChatMessageReadReceipt(CommunicationIdentifier sender, string chatMessageId, DateTimeOffset readOn)
 => new ChatMessageReadReceipt(sender, chatMessageId, readOn);
Ejemplo n.º 30
0
        /// <summary> Add a participant to the call. </summary>
        /// <param name="participant"> The identity of participant to be added to the call. </param>
        /// <param name="alternateCallerId">The phone number to use when adding a pstn participant.</param>
        /// <param name="operationContext">The operation context. </param>
        /// <param name="cancellationToken"> The cancellation token. </param>
        /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
        /// <exception cref="ArgumentNullException"> <paramref name="participant"/> is null. </exception>
        public virtual async Task <Response <AddParticipantResult> > AddParticipantAsync(CommunicationIdentifier participant, string alternateCallerId = default, string operationContext = default, CancellationToken cancellationToken = default)
        {
            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CallConnection)}.{nameof(AddParticipant)}");
            scope.Start();
            try
            {
                Argument.AssertNotNull(participant, nameof(participant));

                return(await RestClient.AddParticipantAsync(
                           callConnectionId : CallConnectionId,
                           participant : CommunicationIdentifierSerializer.Serialize(participant),
                           alternateCallerId : alternateCallerId == null?null : new PhoneNumberIdentifierModel(alternateCallerId),
                           operationContext : operationContext,
                           callbackUri : null,
                           cancellationToken : cancellationToken
                           ).ConfigureAwait(false));
            }
            catch (Exception ex)
            {
                scope.Failed(ex);
                throw;
            }
        }