public Task Handle(ParticipantSubscriptionsUpdatedNotification notification, CancellationToken cancellationToken) { return(_mediator.Send( new UpdateSynchronizedObjectRequest(notification.Participant.ConferenceId, SynchronizedSubscriptions.SyncObjId(notification.Participant.Id)), cancellationToken)); }
public async Task SendPrivateChatMessage_ParticipantConnected_ReceiveNotificationAndAddToSubscriptions() { const string message = "Hello"; // arrange var(connection, conference) = await ConnectToOpenedConference(); var olaf = CreateUser(); var olafConnection = await ConnectUserToConference(olaf, conference); var channel = ChannelSerializer .Encode(new PrivateChatChannel(new HashSet <string> { olaf.Sub, Moderator.Sub })).ToString(); var chatMessageNotification = new TaskCompletionSource <ChatMessageDto>(); olafConnection.Hub.On(CoreHubMessages.ChatMessage, (ChatMessageDto dto) => chatMessageNotification.SetResult(dto)); // act await connection.Hub.InvokeAsync(nameof(CoreHub.SendChatMessage), new SendChatMessageDto(message, channel, new ChatMessageOptions())); // assert await chatMessageNotification.Task.WithDefaultTimeout(); var syncSubscriptionsId = SynchronizedSubscriptions.SyncObjId(connection.User.Sub); await connection.SyncObjects.AssertSyncObject <SynchronizedSubscriptions>(syncSubscriptionsId, value => Assert.Contains(value.Subscriptions.Keys, x => x == channel)); }
private async Task <string> SetupTestRoomChannelAndMoveToRoom(UserConnection connection) { var subscriptionsId = SynchronizedSubscriptions.SyncObjId(connection.User.Sub); // create room var testRoom = (await connection.Hub.InvokeAsync <SuccessOrError <IReadOnlyList <Room> > >( nameof(CoreHub.CreateRooms), new List <RoomCreationInfo> { new("TestRoom") })).Response !.Single();
private async Task <IEnumerable <SynchronizedObjectId> > WaitForSubscriptions(UserConnection connection) { var syncSubscriptionsId = SynchronizedSubscriptions.SyncObjId(connection.User.Sub); await connection.SyncObjects.AssertSyncObject <SynchronizedSubscriptions>(syncSubscriptionsId, value => Assert.Contains(value.Subscriptions.Keys.Select(SynchronizedObjectId.Parse), x => x.Id == SynchronizedObjectIds.SUBSCRIPTIONS)); return(connection.SyncObjects.GetSynchronizedObject <SynchronizedSubscriptions>(syncSubscriptionsId) .Subscriptions.Keys.Select(SynchronizedObjectId.Parse)); }
public async Task Join_ConferenceOpen_ReceiveSubscriptions() { var syncObjId = SynchronizedSubscriptions.SyncObjId(Moderator.Sub); // arrange var(connection, _) = await ConnectToOpenedConference(); // act var subscriptions = await connection.SyncObjects.WaitForSyncObj <SynchronizedSubscriptions>(syncObjId); // assert Assert.NotEmpty(subscriptions.Subscriptions); }
private async ValueTask SendCurrentSynchronizedObjectValues(Participant participant, IEnumerable <SynchronizedObjectId> subscriptions) { var syncSubscriptionsObjId = SynchronizedSubscriptions.SyncObjId(participant.Id).ToString(); foreach (var syncObjId in subscriptions) { _logger.LogDebug("Send current value of {syncObId} to participant.", syncObjId); // subscriptions are updated anyways after this handler completed if (syncObjId.ToString() == syncSubscriptionsObjId) { continue; } await SendCurrentSynchronizedObjectValue(participant, syncObjId); } }