/// <summary>
        /// Initializes a new instance of the <see cref="HubConnectionHandler{THub}"/> class.
        /// </summary>
        /// <param name="lifetimeManager">The hub lifetime manager.</param>
        /// <param name="protocolResolver">The protocol resolver used to resolve the protocols between client and server.</param>
        /// <param name="globalHubOptions">The global options used to initialize hubs.</param>
        /// <param name="hubOptions">Hub specific options used to initialize hubs. These options override the global options.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="userIdProvider">The user ID provider used to get the user ID from a hub connection.</param>
        /// <param name="serviceScopeFactory">The service scope factory.</param>
        /// <remarks>This class is typically created via dependency injection.</remarks>
        public HubConnectionHandler(HubLifetimeManager <THub> lifetimeManager,
                                    IHubProtocolResolver protocolResolver,
                                    IOptions <HubOptions> globalHubOptions,
                                    IOptions <HubOptions <THub> > hubOptions,
                                    ILoggerFactory loggerFactory,
                                    IUserIdProvider userIdProvider,
                                    IServiceScopeFactory serviceScopeFactory
                                    )
        {
            _protocolResolver = protocolResolver;
            _lifetimeManager  = lifetimeManager;
            _loggerFactory    = loggerFactory;
            _hubOptions       = hubOptions.Value;
            _globalHubOptions = globalHubOptions.Value;
            _logger           = loggerFactory.CreateLogger <HubConnectionHandler <THub> >();
            _userIdProvider   = userIdProvider;

            _enableDetailedErrors = _hubOptions.EnableDetailedErrors ?? _globalHubOptions.EnableDetailedErrors ?? false;
            _maximumMessageSize   = _hubOptions.MaximumReceiveMessageSize ?? _globalHubOptions.MaximumReceiveMessageSize;

            _dispatcher = new DefaultHubDispatcher <THub>(
                serviceScopeFactory,
                new HubContext <THub>(lifetimeManager),
                hubOptions,
                globalHubOptions,
                new Logger <DefaultHubDispatcher <THub> >(loggerFactory));
        }
예제 #2
0
 public HubEndPoint(HubLifetimeManager <THub> lifetimeManager,
                    IHubContext <THub> hubContext,
                    InvocationAdapterRegistry registry,
                    ILogger <HubEndPoint <THub> > logger,
                    IServiceScopeFactory serviceScopeFactory) : base(lifetimeManager, hubContext, registry, logger, serviceScopeFactory)
 {
 }
예제 #3
0
        public HubContext(HubLifetimeManager <THub> lifetimeManager)
        {
            _lifetimeManager = lifetimeManager;
            All = TypedClientBuilder <T> .Build(new AllClientProxy <THub>(_lifetimeManager));

            Groups = new GroupManager <THub>(lifetimeManager);
        }
예제 #4
0
 private static async Task InvokeConnectionAsync(HubLifetimeManager <ClientHub> clientHubManager,
                                                 HubMethodInvocationMessage message)
 {
     if (message.TryGetConnectionId(out var connectionId))
     {
         await clientHubManager.InvokeConnectionAsync(connectionId, message.Target, message.Arguments);
     }
 }
예제 #5
0
 private static async Task RemoveGroupAsync(HubLifetimeManager <ClientHub> clientHubManager,
                                            HubMethodInvocationMessage message)
 {
     if (message.TryGetGroupName(out var groupName) &&
         message.TryGetConnectionId(out var connectionId))
     {
         await clientHubManager.RemoveGroupAsync(connectionId, groupName);
     }
 }
예제 #6
0
 private static async Task InvokeGroupAsync(HubLifetimeManager <ClientHub> clientHubManager,
                                            HubMethodInvocationMessage message)
 {
     if (message.TryGetGroupName(out var groupName))
     {
         await clientHubManager.InvokeGroupAsync(groupName, message.Target,
                                                 message.Arguments);
     }
 }
예제 #7
0
 private static async Task InvokeAllExceptAsync(HubLifetimeManager <ClientHub> clientHubManager,
                                                HubMethodInvocationMessage message)
 {
     if (message.TryGetExcludedIds(out var excludedIds))
     {
         await clientHubManager.InvokeAllExceptAsync(message.Target, message.Arguments,
                                                     excludedIds);
     }
 }
예제 #8
0
        public HubServer(HubLifetimeManager <THub> lifetimeManager,
                         IHubInvoker <THub> hubInvoker,
                         ILoggerFactory loggerFactory)
        {
            _lifetimeManager = lifetimeManager;
            _hubInvoker      = hubInvoker;

            _loggerFactory = loggerFactory;
            _logger        = loggerFactory.CreateLogger <HubServer <THub> >();
        }
예제 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HubConnectionHandler{THub}"/> class.
        /// </summary>
        /// <param name="lifetimeManager">The hub lifetime manager.</param>
        /// <param name="protocolResolver">The protocol resolver used to resolve the protocols between client and server.</param>
        /// <param name="globalHubOptions">The global options used to initialize hubs.</param>
        /// <param name="hubOptions">Hub specific options used to initialize hubs. These options override the global options.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="userIdProvider">The user ID provider used to get the user ID from a hub connection.</param>
        /// <param name="serviceScopeFactory">The service scope factory.</param>
        /// <remarks>This class is typically created via dependency injection.</remarks>
        public HubConnectionHandler(HubLifetimeManager <THub> lifetimeManager,
                                    IHubProtocolResolver protocolResolver,
                                    IOptions <HubOptions> globalHubOptions,
                                    IOptions <HubOptions <THub> > hubOptions,
                                    ILoggerFactory loggerFactory,
                                    IUserIdProvider userIdProvider,
                                    IServiceScopeFactory serviceScopeFactory
                                    )
        {
            _protocolResolver = protocolResolver;
            _lifetimeManager  = lifetimeManager;
            _loggerFactory    = loggerFactory;
            _hubOptions       = hubOptions.Value;
            _globalHubOptions = globalHubOptions.Value;
            _logger           = loggerFactory.CreateLogger <HubConnectionHandler <THub> >();
            _userIdProvider   = userIdProvider;

            _enableDetailedErrors = false;

            List <IHubFilter> hubFilters = null;

            if (_hubOptions.UserHasSetValues)
            {
                _maximumMessageSize   = _hubOptions.MaximumReceiveMessageSize;
                _enableDetailedErrors = _hubOptions.EnableDetailedErrors ?? _enableDetailedErrors;

                if (_hubOptions.HubFilters != null)
                {
                    hubFilters = new List <IHubFilter>();
                    hubFilters.AddRange(_hubOptions.HubFilters);
                }
            }
            else
            {
                _maximumMessageSize   = _globalHubOptions.MaximumReceiveMessageSize;
                _enableDetailedErrors = _globalHubOptions.EnableDetailedErrors ?? _enableDetailedErrors;

                if (_globalHubOptions.HubFilters != null)
                {
                    hubFilters = new List <IHubFilter>();
                    hubFilters.AddRange(_globalHubOptions.HubFilters);
                }
            }

            _dispatcher = new DefaultHubDispatcher <THub>(
                serviceScopeFactory,
                new HubContext <THub>(lifetimeManager),
                _enableDetailedErrors,
                new Logger <DefaultHubDispatcher <THub> >(loggerFactory),
                hubFilters);
        }
예제 #10
0
 public HubEndPoint(HubLifetimeManager <THub> lifetimeManager,
                    IHubProtocolResolver protocolResolver,
                    IOptions <HubOptions> hubOptions,
                    ILoggerFactory loggerFactory,
                    IUserIdProvider userIdProvider,
                    IHubInvoker <THub> hubInvoker)
 {
     _protocolResolver = protocolResolver;
     _lifetimeManager  = lifetimeManager;
     _loggerFactory    = loggerFactory;
     _hubOptions       = hubOptions.Value;
     _logger           = loggerFactory.CreateLogger <HubEndPoint <THub> >();
     _userIdProvider   = userIdProvider;
     _hubInvoker       = hubInvoker;
 }
예제 #11
0
        public HubEndPoint(HubLifetimeManager <THub> lifetimeManager,
                           IHubProtocolResolver protocolResolver,
                           IHubContext <THub> hubContext,
                           IOptions <HubOptions> hubOptions,
                           ILogger <HubEndPoint <THub> > logger,
                           IServiceScopeFactory serviceScopeFactory)
        {
            _protocolResolver    = protocolResolver;
            _lifetimeManager     = lifetimeManager;
            _hubContext          = hubContext;
            _hubOptions          = hubOptions;
            _logger              = logger;
            _serviceScopeFactory = serviceScopeFactory;

            DiscoverHubMethods();
        }
예제 #12
0
 public HubEndPoint(HubLifetimeManager <THub> lifetimeManager,
                    IHubProtocolResolver protocolResolver,
                    IOptions <HubOptions> globalHubOptions,
                    IOptions <HubOptions <THub> > hubOptions,
                    ILoggerFactory loggerFactory,
                    IUserIdProvider userIdProvider,
                    HubDispatcher <THub> dispatcher)
 {
     _protocolResolver = protocolResolver;
     _lifetimeManager  = lifetimeManager;
     _loggerFactory    = loggerFactory;
     _hubOptions       = hubOptions.Value;
     _globalHubOptions = globalHubOptions.Value;
     _logger           = loggerFactory.CreateLogger <HubEndPoint <THub> >();
     _userIdProvider   = userIdProvider;
     _dispatcher       = dispatcher;
 }
예제 #13
0
        public HubConnectionHandler(HubLifetimeManager <THub> lifetimeManager,
                                    IHubProtocolResolver protocolResolver,
                                    IOptions <HubOptions> globalHubOptions,
                                    IOptions <HubOptions <THub> > hubOptions,
                                    ILoggerFactory loggerFactory,
                                    IUserIdProvider userIdProvider,
                                    HubDispatcher <THub> dispatcher)
        {
            _protocolResolver = protocolResolver;
            _lifetimeManager  = lifetimeManager;
            _loggerFactory    = loggerFactory;
            _hubOptions       = hubOptions.Value;
            _globalHubOptions = globalHubOptions.Value;
            _logger           = loggerFactory.CreateLogger <HubConnectionHandler <THub> >();
            _userIdProvider   = userIdProvider;
            _dispatcher       = dispatcher;

            _enableDetailedErrors = _hubOptions.EnableDetailedErrors ?? _globalHubOptions.EnableDetailedErrors ?? false;
        }
예제 #14
0
        public ServiceConnection(IConnection connection,
                                 IHubProtocol protocol,
                                 HubLifetimeManager <THub> lifetimeManager,
                                 IHubInvoker <THub> hubInvoker,
                                 ILoggerFactory loggerFactory)
        {
            _connection      = connection ?? throw new ArgumentNullException(nameof(connection));
            _protocol        = protocol ?? throw new ArgumentNullException(nameof(protocol));
            _loggerFactory   = loggerFactory ?? NullLoggerFactory.Instance;
            _logger          = _loggerFactory.CreateLogger <ServiceConnection <THub> >();
            _hubInvoker      = hubInvoker;
            _lifetimeManager = lifetimeManager;
            _output          = Channel.CreateUnbounded <HubMessage>();

            // Create the timer for timeout, but disabled by default (we enable it when started).
            _timeoutTimer = new Timer(state => ((ServiceConnection <THub>)state).TimeoutElapsed(), this, Timeout.Infinite, Timeout.Infinite);

            connection.OnReceived((data, state) => ((ServiceConnection <THub>)state).OnDataReceivedAsync(data), this);
        }
예제 #15
0
        public HubEndPoint(HubLifetimeManager <THub> lifetimeManager,
                           IHubProtocolResolver protocolResolver,
                           IHubContext <THub> hubContext,
                           IOptions <HubOptions> hubOptions,
                           ILoggerFactory loggerFactory,
                           IServiceScopeFactory serviceScopeFactory,
                           IUserIdProvider userIdProvider)
        {
            _protocolResolver    = protocolResolver;
            _lifetimeManager     = lifetimeManager;
            _hubContext          = hubContext;
            _loggerFactory       = loggerFactory;
            _hubOptions          = hubOptions.Value;
            _logger              = loggerFactory.CreateLogger <HubEndPoint <THub> >();
            _serviceScopeFactory = serviceScopeFactory;
            _userIdProvider      = userIdProvider;

            DiscoverHubMethods();
        }
예제 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HubConnectionHandler{THub}"/> class.
        /// </summary>
        /// <param name="lifetimeManager">The hub lifetime manager.</param>
        /// <param name="protocolResolver">The protocol resolver used to resolve the protocols between client and server.</param>
        /// <param name="globalHubOptions">The global options used to initialize hubs.</param>
        /// <param name="hubOptions">Hub specific options used to initialize hubs. These options override the global options.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="userIdProvider">The user ID provider used to get the user ID from a hub connection.</param>
        /// <param name="dispatcher">The hub dispatcher used to dispatch incoming messages to hubs.</param>
        /// <remarks>This class is typically created via dependency injection.</remarks>
        public HubConnectionHandler(HubLifetimeManager <THub> lifetimeManager,
                                    IHubProtocolResolver protocolResolver,
                                    IOptions <HubOptions> globalHubOptions,
                                    IOptions <HubOptions <THub> > hubOptions,
                                    ILoggerFactory loggerFactory,
                                    IUserIdProvider userIdProvider,
#pragma warning disable PUB0001 // Pubternal type in public API
                                    HubDispatcher <THub> dispatcher
#pragma warning restore PUB0001
                                    )
        {
            _protocolResolver = protocolResolver;
            _lifetimeManager  = lifetimeManager;
            _loggerFactory    = loggerFactory;
            _hubOptions       = hubOptions.Value;
            _globalHubOptions = globalHubOptions.Value;
            _logger           = loggerFactory.CreateLogger <HubConnectionHandler <THub> >();
            _userIdProvider   = userIdProvider;
            _dispatcher       = dispatcher;

            _enableDetailedErrors = _hubOptions.EnableDetailedErrors ?? _globalHubOptions.EnableDetailedErrors ?? false;
        }
예제 #17
0
 public AllClientProxy(HubLifetimeManager <THub> lifetimeManager)
 {
     _lifetimeManager = lifetimeManager;
 }
예제 #18
0
 public GroupExceptProxy(HubLifetimeManager <THub> lifetimeManager, string groupName, IReadOnlyList <string> excludedIds)
 {
     _lifetimeManager = lifetimeManager;
     _groupName       = groupName;
     _excludedIds     = excludedIds;
 }
예제 #19
0
 public MultipleGroupProxy(HubLifetimeManager <THub> lifetimeManager, IReadOnlyList <string> groupNames)
 {
     _lifetimeManager = lifetimeManager;
     _groupNames      = groupNames;
 }
예제 #20
0
 public GroupProxy(HubLifetimeManager <THub> lifetimeManager, string groupName)
 {
     _lifetimeManager = lifetimeManager;
     _groupName       = groupName;
 }
예제 #21
0
 public MultipleUserProxy(HubLifetimeManager <THub> lifetimeManager, IReadOnlyList <string> userIds)
 {
     _lifetimeManager = lifetimeManager;
     _userIds         = userIds;
 }
예제 #22
0
 public GroupManager(HubLifetimeManager <THub> lifetimeManager)
 {
     _lifetimeManager = lifetimeManager;
 }
예제 #23
0
 public MultipleClientProxy(HubLifetimeManager <THub> lifetimeManager, IReadOnlyList <string> connectionIds)
 {
     _lifetimeManager = lifetimeManager;
     _connectionIds   = connectionIds;
 }
예제 #24
0
 public SingleClientProxy(HubLifetimeManager <THub> lifetimeManager, string connectionId)
 {
     _lifetimeManager = lifetimeManager;
     _connectionId    = connectionId;
 }
예제 #25
0
 public UserProxy(HubLifetimeManager <THub> lifetimeManager, string userId)
 {
     _lifetimeManager = lifetimeManager;
     _userId          = userId;
 }
예제 #26
0
 public AllClientsExceptProxy(HubLifetimeManager <THub> lifetimeManager, IReadOnlyList <string> excludedIds)
 {
     _lifetimeManager = lifetimeManager;
     _excludedIds     = excludedIds;
 }
예제 #27
0
 public HubContext(HubLifetimeManager <THub> lifetimeManager)
 {
     _lifetimeManager = lifetimeManager;
     _clients         = new HubClients <THub, T>(_lifetimeManager);
     Groups           = new GroupManager <THub>(lifetimeManager);
 }
예제 #28
0
 public HubClients(HubLifetimeManager <THub> lifetimeManager)
 {
     _lifetimeManager = lifetimeManager;
     All = TypedClientBuilder <T> .Build(new AllClientProxy <THub>(_lifetimeManager));
 }
예제 #29
0
 private static async Task InvokeAllAsync(HubLifetimeManager <ClientHub> clientHubManager,
                                          HubMethodInvocationMessage message)
 {
     await clientHubManager.InvokeAllAsync(message.Target, message.Arguments);
 }
예제 #30
0
파일: HubClients.cs 프로젝트: zjnny/SignalR
 public HubClients(HubLifetimeManager <THub> lifetimeManager)
 {
     _lifetimeManager = lifetimeManager;
     All = new AllClientProxy <THub>(_lifetimeManager);
 }