Пример #1
0
        /// <summary>
        /// Upon closing the window or exiting the application this is called to make sure the other users
        /// no longer see the user who has left.
        /// </summary>
        /// <param name="user">User who has left the application.</param>
        /// <returns></returns>
        public async Task RemoveUser(User user)
        {
            var connectionId = Context.ConnectionId;

            _users.Remove(connectionId);
            await Clients.All.SendAsync("removeUser", _users.GetUsers());
        }
Пример #2
0
        public override async Task OnDisconnectedAsync(Exception exception)
        {
            string name = Context.User.Identity.Name;

            _connections.Remove(name, Context.ConnectionId);
            await Groups.RemoveFromGroupAsync(Context.ConnectionId, "Users");

            await base.OnDisconnectedAsync(exception);
        }