public override Task OnDisconnected(bool stopCalled) { string name = Context.QueryString["username"]; _connections.Remove(name, Context.ConnectionId); _logger.Info($"{name} has left the chat room"); return(base.OnDisconnected(stopCalled)); }
public override Task OnDisconnectedAsync(Exception exception) { var connectionId = Context.ConnectionId; var email = Context.User.Identity.Name; // TODO: условие нужно потому что еще нет авторизации по сокетам if (!string.IsNullOrEmpty(email)) { _connectionMapping.Remove(email, connectionId); } return(base.OnDisconnectedAsync(exception)); }
public override async Task OnDisconnectedAsync(Exception ex) { var identity = Context.User.Identity; var connectionId = Context.ConnectionId; if (identity.IsAuthenticated) { await _connectionMapping.Remove(connectionId); //await Groups.AddToGroupAsync(Context.ConnectionId, groupName: (identity.Name)).ConfigureAwait(false); } //await Clients.All.SendAsync("SendAction", Context.User.Identity.Name, "left"); }
//TODO: INvoke this method when user logOut public override Task OnDisconnectedAsync(Exception exception) { Groups.RemoveFromGroupAsync(Context.ConnectionId, Context.User.Identity.Name); connections.Remove(Context.User.Identity.Name, Context.ConnectionId); var connectionsCount = connections.GetConnections(Context.User.Identity.Name); //Cheking does this user has any connetctions, if not send status to front end if (connectionsCount.Count() == 0) { Clients.All.SendAsync("ReciveDisconnectedStatus", Context.User.Identity.Name); } //Here we can check is user have any connectons if not SendMessage to the Client side return(base.OnDisconnectedAsync(exception)); }