Exemplo n.º 1
0
        public override async Task OnConnectedAsync(HubConnectionContext connection)
        {
            await _wrappedHubLifetimeManager.OnConnectedAsync(connection);

            _connections.Add(connection);
            await _userTracker.AddUser(connection.ConnectionId, new UserDetails(connection.ConnectionId, connection.User.Identity.Name, Guid.NewGuid().ToString()));
        }
Exemplo n.º 2
0
        public override async Task OnConnectedAsync(HubConnectionContext connection)
        {
            await EnsureStreamSetup();

            try
            {
                _connections.Add(connection);

                var client = _clusterClientProvider.GetClient().GetClientGrain(_hubName, connection.ConnectionId);
                await client.OnConnect(_serverId);

                if (connection !.User !.Identity !.IsAuthenticated)
                {
                    var user = _clusterClientProvider.GetClient().GetUserGrain(_hubName, connection.UserIdentifier !);
                    await user.Add(connection.ConnectionId);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex,
                                 "An error has occurred 'OnConnectedAsync' while adding connection {connectionId} [hub: {hubName} (serverId: {serverId})]",
                                 connection?.ConnectionId, _hubName, _serverId);
                _connections.Remove(connection !);
                throw;
            }
        }
        public override async Task OnConnectedAsync(HubConnectionContext connection)
        {
            await EnsureRedisServerConnection();

            var connectionTask = Task.CompletedTask;
            var userTask       = Task.CompletedTask;

            _connections.Add(connection);

            await Task.WhenAll(connectionTask, userTask);
        }
Exemplo n.º 4
0
        private async Task AddGroup(HubConnectionContext connection, string group)
        {
            await _Lock.WaitAsync();

            try
            {
                HubConnectionStore subscription = this._Groups.GetOrAdd(group, _ => new HubConnectionStore());
                subscription.Add(connection);
            }
            finally
            {
                _Lock.Release();
            }
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public override Task OnConnectedAsync(HubConnectionContext connection)
        {
            _connections.Add(connection);

            var actions = new List <DirectoryAction>();

            actions.Add(DirectoryAction.AddConnection(_hubName, connection.ConnectionId));

            if (!string.IsNullOrEmpty(connection.UserIdentifier))
            {
                actions.Add(DirectoryAction.AddUser(_hubName, connection.UserIdentifier));
            }

            return(_localDirectory.PerformActions(actions));
        }
        public override async Task OnConnectedAsync(HubConnectionContext connection)
        {
            await EnsureRedisServerConnection();

            var feature = new RedisFeature();

            connection.Features.Set <IRedisFeature>(feature);

            _connections.Add(connection);

            var connectionTask = SubscribeToConnection(connection);
            var userTask       = SubscribeToUser(connection);

            await Task.WhenAll(connectionTask, userTask);
        }
Exemplo n.º 7
0
        public async Task SubscribeToUser(HubConnectionContext connection)
        {
            await _UserLock.WaitAsync();

            try
            {
                HubConnectionStore subscription = this._Users.GetOrAdd(connection.UserIdentifier, _ => new HubConnectionStore());
                subscription.Add(connection);
                RabbitMQLog.Subscribing(_Logger, "SubscribeToUser:" + connection.ConnectionId);
            }
            finally
            {
                _UserLock.Release();
            }
        }
Exemplo n.º 8
0
    /// <inheritdoc />
    public override async Task OnConnectedAsync(HubConnectionContext connection)
    {
        await EnsureRedisServerConnection();

        var feature = new RedisFeature();

        connection.Features.Set <IRedisFeature>(feature);

        var userTask = Task.CompletedTask;

        _connections.Add(connection);

        var connectionTask = SubscribeToConnection(connection);

        if (!string.IsNullOrEmpty(connection.UserIdentifier))
        {
            userTask = SubscribeToUser(connection);
        }

        await Task.WhenAll(connectionTask, userTask);
    }
Exemplo n.º 9
0
 /// <inheritdoc />
 public override Task OnConnectedAsync(HubConnectionContext connection)
 {
     _connections.Add(connection);
     return(Task.CompletedTask);
 }