예제 #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
파일: VoteHub.cs 프로젝트: daniefer/Vote
        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);
        }