コード例 #1
0
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            if (!_authService.IsAuthorized())
            {
                return;
            }

            var user = await _authService.GetAuthorizedUser();

            var userChannels = await _chatService.GetUserChannels(user.Id);

            foreach (var channel in userChannels)
            {
                await _provider.UserDisconnectedFromServer(user, channel.Id);

                await Groups.RemoveFromGroupAsync(Context.ConnectionId, channel.Id.ToString());
            }

            await _connectionsStore.RemoveUserConnection();
        }