Beispiel #1
0
        public async Task Should_send_endpoint_status_messages_to_clients(RoomType from, RoomType to,
                                                                          EndpointState status)
        {
            _eventHandler = new EndpointTransferEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object,
                                                             VideoApiClientMock.Object);

            var conference          = TestConference;
            var participantCount    = conference.Participants.Count + 1; // plus one for admin
            var participantForEvent = conference.Endpoints.First();
            var callbackEvent       = new CallbackEvent
            {
                EventType     = EventType.EndpointTransfer,
                EventId       = Guid.NewGuid().ToString(),
                ParticipantId = participantForEvent.Id,
                TransferFrom  = from,
                TransferTo    = to,
                ConferenceId  = conference.Id,
                Reason        = "JVC Connection",
                TimeStampUtc  = DateTime.UtcNow
            };

            await _eventHandler.HandleAsync(callbackEvent);

            // Verify messages sent to event hub clients
            EventHubClientMock.Verify(x => x.EndpointStatusMessage(participantForEvent.Id, conference.Id, status),
                                      Times.Exactly(participantCount));
        }
        protected async Task PublishEndpointStatusMessage(EndpointState endpointState)
        {
            foreach (var participant in SourceConference.Participants)
            {
                await HubContext.Clients.Group(participant.Username.ToLowerInvariant())
                .EndpointStatusMessage(SourceEndpoint.Id, SourceConference.Id, endpointState);
            }

            await HubContext.Clients.Group(Hub.EventHub.VhOfficersGroupName)
            .EndpointStatusMessage(SourceEndpoint.Id, SourceConference.Id, endpointState);

            Logger.LogTrace($"Endpoint Status: Endpoint Id: { SourceEndpoint.Id } | " +
                            $"Endpoint State: { endpointState } | Timestamp: { (DateTime.Now) :yyyy-MM-dd HH:mm:ss.fffffff} ");
        }
        protected async Task PublishEndpointStatusMessage(EndpointState endpointState)
        {
            foreach (var participant in SourceConference.Participants)
            {
                await HubContext.Clients.Group(participant.Username.ToLowerInvariant())
                .EndpointStatusMessage(SourceEndpoint.Id, SourceConference.Id, endpointState);
            }

            await HubContext.Clients.Group(Hub.EventHub.VhOfficersGroupName)
            .EndpointStatusMessage(SourceEndpoint.Id, SourceConference.Id, endpointState);

            Logger.LogTrace("Endpoint Status: Endpoint Id: {SourceEndpointId} | Endpoint State: {EndpointState}",
                            SourceEndpoint.Id, endpointState);
        }