コード例 #1
0
        public async Task UserDisconnectedFromServer(ApplicationUser user, Guid channelId)
        {
            var eventData = new UserJoinedEventData
            {
                UserId   = user.Id,
                Username = user.UserName
            };

            await SendEventToGroup(channelId, ChatEvent.UserDisconnected, eventData);
        }
コード例 #2
0
        public async Task UserLeftFromChannel(ApplicationUser user, Guid channelId)
        {
            var userConnection = await _connectionsStore.GetUserConnection(user.Id);

            var eventData = new UserJoinedEventData
            {
                UserId   = user.Id,
                Username = user.UserName
            };

            await SendEventToGroup(channelId, ChatEvent.UserLeft, eventData);

            if (userConnection != null)
            {
                await _hubContext.Groups.RemoveFromGroupAsync(userConnection, channelId.ToString());
            }
        }