Пример #1
0
        public override async Task OnConnectedAsync()
        {
            var userName = Context.User.GetUserName();
            var isOnline = await _tracker.UserConnected(userName, Context.ConnectionId);

            if (isOnline)
            {
                await Clients.Others.SendAsync("UserIsOnline", userName);
            }

            var connectedUsers = await _tracker.GetUsersOnline();

            await Clients.Caller.SendAsync("GetUsersOnline", connectedUsers);
        }