public override async Task OnConnectedAsync() { string name = Context.User.Identity.Name; ConnectionMapping <string> .Add(name, Context.ConnectionId); await base.OnConnectedAsync(); }
public override async Task OnConnectedAsync() { var httpContext = Context.GetHttpContext(); if (httpContext != null) { try { //Add Logged User var userName = httpContext.Request.Query["user"].ToString(); //var UserAgent = httpContext.Request.Headers["User-Agent"].FirstOrDefault().ToString(); var connId = Context.ConnectionId.ToString(); _connections.Add(userName, connId); //Update Client await Clients.All.SendAsync("UpdateUserList", _connections.ToJson()); } catch (Exception) { } } }