public override async Task OnConnectedAsync(HubConnectionContext connection) { await _wrappedHubLifetimeManager.OnConnectedAsync(connection); _connections.Add(connection); await _userTracker.AddUser(connection, new UserDetails(connection.ConnectionId, connection.User.Identity.Name)); }
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(); }
public override async Task OnConnectedAsync(HubConnectionContext connection) { await _wrappedHubLifetimeManager.OnConnectedAsync(connection); _connections.Add(connection); var httpContext = connection.GetHttpContext(); var role = httpContext.User?.FindFirstValue(ClaimTypes.Role) ?? ""; var email = httpContext.User?.FindFirst(ClaimTypes.Email).Value ?? ""; var livechatId = httpContext.User?.FindFirstValue("LivechatUserId") ?? ""; var authToken = httpContext.User?.FindFirstValue("AuthToken") ?? ""; var device = httpContext.User?.FindFirstValue("Device") ?? ""; var version = httpContext.User?.FindFirstValue("Version") ?? ""; var nopCustomerId = int.Parse(httpContext.User?.FindFirstValue("CustomerId") ?? "0"); var agentStores = httpContext.User?.FindFirstValue("Stores"); var storesParsed = string.IsNullOrEmpty(agentStores) ? new List <int>() : agentStores? .Split(',')? .Select(t => int.Parse(t))? .ToList() ?? new List <int>(); var userPayloadString = httpContext.User?.FindFirstValue("UserPayload") ?? ""; var userPayload = new Dictionary <string, object>(); // StoreId from livechat user var customerStoreIdHeader = httpContext.Request.Headers["storeId"]; if (!int.TryParse(customerStoreIdHeader, out var customerStoreId)) { customerStoreId = 0; } if (!string.IsNullOrEmpty(userPayloadString)) { userPayload = JsonConvert.DeserializeObject <Dictionary <string, object> >(userPayloadString); } await _userTracker.AddUser ( connection, new UserDetails ( connection.ConnectionId, connection.User.Identity.Name ) { LivechatUserId = livechatId, Role = role, Stores = storesParsed, Email = email, CustomerStoreId = customerStoreId, Payload = userPayload, CustomerId = nopCustomerId, AuthToken = authToken, Device = device, Version = version } ); }
public override Task OnConnectedAsync() { var name = Context.User?.Identity?.Name; var sessionId = Context.User?.FindFirstValue("sid"); var user = _userService.AddUser(sessionId, name); Clients.All.SendAsync("UserLoggedOn", user); return(base.OnConnectedAsync()); }
public IActionResult Index() { var user = HttpContext.User?.Identity as ClaimsIdentity; if (user != null && user.IsAuthenticated) { _userTracker.AddUser(user.FindFirst("sid").Value, user.Name); } return View(); }
public override async Task OnConnectedAsync() { var currentUser = new UserDetails(Context.ConnectionId, Context.User.Identity.Name); userTracker.AddUser(currentUser); await OnUsersJoined(currentUser); await Clients.Client(Context.ConnectionId).InvokeAsync("SetUsersOnline", userTracker.GetUsers()); await base.OnConnectedAsync(); }
/// <summary> /// Invoked from WebsocketService in ClientApp when the connection is successfully created /// </summary> /// <param name="username"></param> public void UserConnected(string username) { var id = Context.ConnectionId; _userTracker.AddUser(id, username); }
public override Task OnConnectedAsync() { _userTracker.AddUser(Context.UserIdentifier); return(base.OnConnectedAsync()); }
public override async Task OnConnectedAsync() { await base.OnConnectedAsync(); _userTracker.AddUser(Context.Connection, new UserDetails(Context.Connection.ConnectionId, Context.Connection.User?.Identity?.Name ?? "RepSupreme")); await Clients.All.Counter(_userTracker.UsersOnline().Count()); }