Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 4
0
        //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));
        }