Beispiel #1
0
        public async Task ChangeParticipantProducer_SendMessageToSfu()
        {
            // arrange
            var conference = await CreateConference(Moderator);

            var connection = await ConnectUserToConference(Moderator, conference);

            var request = new ChangeParticipantProducerDto("123", ProducerSource.Mic, MediaStreamAction.Pause);

            var observer = ConnectPublishObserver();

            observer.Setup(x => x.PostPublish(It.IsAny <PublishContext <ChangeParticipantProducer> >())).Callback(
                (PublishContext <ChangeParticipantProducer> context) =>
            {
                var dto = context.Message;
                Assert.Equal(conference.ConferenceId, dto.ConferenceId);
                Assert.Equal(request.ParticipantId, dto.Payload.ParticipantId);
                Assert.Equal(request.Source, dto.Payload.Source);
                Assert.Equal(request.Action, dto.Payload.Action);
            });

            // act
            var result =
                await connection.Hub.InvokeAsync <SuccessOrError <Unit> >(nameof(CoreHub.ChangeParticipantProducer),
                                                                          request);

            // assert
            AssertSuccess(result);

            await AssertHelper.WaitForAssert(() =>
            {
                observer.Verify(x => x.PostPublish(It.IsAny <PublishContext <ChangeParticipantProducer> >()),
                                Times.Once);
            });
        }
Beispiel #2
0
        public async Task <SuccessOrError <Unit> > ChangeParticipantProducer(ChangeParticipantProducerDto dto)
        {
            var(conferenceId, _) = GetContextParticipant();

            return(await GetInvoker()
                   .Create(new ChangeParticipantProducerRequest(new Participant(conferenceId, dto.ParticipantId),
                                                                dto.Source, dto.Action))
                   .RequirePermissions(DefinedPermissions.Media.CanChangeOtherParticipantsProducers).Send());
        }
Beispiel #3
0
 public async Task ChangeProducer(string conferenceId, ChangeParticipantProducerDto value)
 {
     await _publishEndpoint.Publish <ChangeParticipantProducer>(
         new { ConferenceId = conferenceId, Type = "ChangeProducer", Payload = value },
         context => SetupContext(context, conferenceId));
 }