public static void AddSignalRHubEndpoints <THub>(this IBusFactoryConfigurator configurator,
                                                         IRegistrationContext <IServiceProvider> context,
                                                         Action <IReceiveEndpointConfigurator> configureEndpoint = null)
            where THub : Hub
        {
            var endpointNameFormatter = context.Container.GetService <IEndpointNameFormatter>();
            var definition            = new HubEndpointDefinition <THub>();

            configurator.ReceiveEndpoint(definition, endpointNameFormatter, e =>
            {
                configureEndpoint?.Invoke(e);

                e.ConfigureConsumer <AllConsumer <THub> >(context);
            });

            configurator.ReceiveEndpoint(definition, endpointNameFormatter, e =>
            {
                configureEndpoint?.Invoke(e);

                e.ConfigureConsumer <ConnectionConsumer <THub> >(context);
            });

            configurator.ReceiveEndpoint(definition, endpointNameFormatter, e =>
            {
                configureEndpoint?.Invoke(e);

                e.ConfigureConsumer <GroupConsumer <THub> >(context);
            });

            configurator.ReceiveEndpoint(definition, endpointNameFormatter, e =>
            {
                configureEndpoint?.Invoke(e);

                e.ConfigureConsumer <UserConsumer <THub> >(context);
            });
        }
Example #2
0
        public static void AddSignalRHubEndpoints <THub>(this IBusFactoryConfigurator configurator,
                                                         IRegistrationContext <IServiceProvider> context,
                                                         Action <IReceiveEndpointConfigurator> configureEndpoint = null)
            where THub : Hub
        {
            // Get the configuration options
            var options = context.Container.GetService <MassTransitSignalROptions>() ?? new MassTransitSignalROptions();
            var hubLifetimeManagerOptions = context.Container.GetRequiredService <HubLifetimeManagerOptions <THub> >();
            var endpointDefinition        = new HubEndpointDefinition <THub>();

            if (options.UseMessageData || hubLifetimeManagerOptions.UseMessageData)
            {
                configurator.UseMessageData(context.Container.GetService <IMessageDataRepository>());
                configurator.ReceiveEndpoint(endpointDefinition, null, e =>
                {
                    configureEndpoint?.Invoke(e);

                    e.ConfigureConsumer <AllMessageDataConsumer <THub> >(context);
                });

                configurator.ReceiveEndpoint(endpointDefinition, null, e =>
                {
                    configureEndpoint?.Invoke(e);

                    e.ConfigureConsumer <ConnectionMessageDataConsumer <THub> >(context);
                });

                configurator.ReceiveEndpoint(endpointDefinition, null, e =>
                {
                    configureEndpoint?.Invoke(e);

                    e.ConfigureConsumer <GroupMessageDataConsumer <THub> >(context);
                });

                configurator.ReceiveEndpoint(endpointDefinition, null, e =>
                {
                    configureEndpoint?.Invoke(e);

                    e.ConfigureConsumer <UserMessageDataConsumer <THub> >(context);
                });
            }
            else
            {
                configurator.ReceiveEndpoint(endpointDefinition, null, e =>
                {
                    configureEndpoint?.Invoke(e);

                    e.ConfigureConsumer <AllConsumer <THub> >(context);
                });

                configurator.ReceiveEndpoint(endpointDefinition, null, e =>
                {
                    configureEndpoint?.Invoke(e);

                    e.ConfigureConsumer <ConnectionConsumer <THub> >(context);
                });

                configurator.ReceiveEndpoint(endpointDefinition, null, e =>
                {
                    configureEndpoint?.Invoke(e);

                    e.ConfigureConsumer <GroupConsumer <THub> >(context);
                });

                configurator.ReceiveEndpoint(endpointDefinition, null, e =>
                {
                    configureEndpoint?.Invoke(e);

                    e.ConfigureConsumer <UserConsumer <THub> >(context);
                });
            }

            // Common Receive Endpoint
            configurator.ReceiveEndpoint(endpointDefinition, null, e =>
            {
                configureEndpoint?.Invoke(e);

                e.ConfigureConsumer <GroupManagementConsumer <THub> >(context);
            });
        }