Пример #1
0
        public override async Task OnConnectedAsync()
        {
            // Update the presence tracker
            var isOnline = await _tracker.UserConncted(Context.User.GetUsername(), Context.ConnectionId);

            if (isOnline)
            {
                await Clients.Others.SendAsync("UserIsOnline", Context.User.GetUsername());
            }

            // send back all connected users
            var currentUSers = await _tracker.GetOnlineUsers();

            await Clients.Caller.SendAsync("GetOnlineUsers", currentUSers);
        }