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

            if (isOnline) //first login for this user, logging in to additional devices won't raise this flag
            {
                await Clients.Others.SendAsync("UserIsOnline", currentUser);
            }

            var currentUsers = await _tracker.GetConnectedUsers();

            await Clients.Caller.SendAsync("GetOnlineUsers", currentUsers);

            //await Clients.All.SendAsync("GetOnlineUsers", currentUsers);
        }