示例#1
0
        public override async Task OnConnectedAsync()
        {
            var owner = await _userManager.GetUserAsync(Context.User);

            var ownerId    = owner.Id;
            var ownerEmail = await _userManager.GetEmailAsync(owner);

            var userDetails = new UserDetails
            {
                ConnectionId = Context.ConnectionId,
                Owner        = new User
                {
                    Email = ownerEmail,
                    Id    = ownerId
                }
            };

            _notificator.AddConnection(Context.Connection);

            //await Clients.Client(Context.ConnectionId).InvokeAsync("OnConnected", "You've connected");

            await _userTracker.AddUser(Context.Connection, userDetails);

            await base.OnConnectedAsync();
        }