Пример #1
0
        public static Task ParticipantChanged(this IHubContext <VoteHub> context, Participant participant, CancellationToken cancellationToken)
        {
            var eventArgs = new ParticipantEventArgs {
                Event = ParticipantEvent.Changed, Participant = participant
            };

            return(context.Clients.Group(participant.RoomId.ToString()).SendAsync(nameof(IClient.ParticipantChanged), eventArgs, cancellationToken));
        }
Пример #2
0
        private async Task NotifyRoomParticipantJoined(int roomId, int participantId, CancellationToken cancellationToken)
        {
            var participant = await _context.Participants.FirstOrDefaultAsync(Participant.GetById(participantId), cancellationToken);

            var eventArgs = new ParticipantEventArgs {
                Event = ParticipantEvent.Joined, Participant = participant
            };
            await Clients.GroupExcept(roomId.ToString(), new[] { Context.ConnectionId }).SendAsync(nameof(IClient.ParticipantChanged), eventArgs);
        }