C# Class Microsoft.AspNetCore.SignalR.Hubs.HubPipelineModule

Common base class to simplify the implementation of IHubPipelineModules. A module can intercept and customize various stages of hub processing such as connecting, reconnecting, disconnecting, invoking server-side hub methods, invoking client-side hub methods, authorizing hub clients and rejoining hub groups. A module can be activated by calling IHubPipeline.AddModule. The combined modules added to the IHubPipeline are invoked via the IHubPipelineInvoker interface.
Inheritance: IHubPipelineModule
Show file Open project: FabianGosebrink/ASPNET-Core-Angular2-SignalR-Typescript

Public Methods

Method Description
BuildAuthorizeConnect ( Func authorizeConnect ) : Func

Wraps a function to be called before a client subscribes to signals belonging to the hub described by the HubDescriptor. By default, the AuthorizeModule will look for attributes on the IHub to help determine if the client is authorized to subscribe to method invocations for the described hub. The function returns true if the client is authorized to subscribe to client-side hub method invocations; false, otherwise.

BuildConnect ( Task>.Func connect ) : Task>.Func

Wraps a function that is called when a client connects to the HubDispatcher for each IHub the client connects to. By default, this results in the IHub's OnConnected method being invoked.

BuildDisconnect ( Func disconnect ) : Func

Wraps a function that is called when a client disconnects from the HubDispatcher for each IHub the client was connected to. By default, this results in the IHub's OnDisconnected method being invoked.

BuildIncoming ( Func invoke ) : Task>.Func

Wraps a function that invokes a server-side hub method. Even if a client has not been authorized to connect to a hub, it will still be authorized to invoke server-side methods on that hub unless it is prevented in IHubPipelineModule.BuildIncoming by not executing the invoke parameter.

BuildOutgoing ( Task>.Func send ) : Task>.Func

Wraps a function that invokes a client-side hub method.

BuildReconnect ( Task>.Func reconnect ) : Task>.Func

Wraps a function that is called when a client reconnects to the HubDispatcher for each IHub the client connects to. By default, this results in the IHub's OnReconnected method being invoked.

BuildRejoiningGroups ( Func rejoiningGroups ) : Func,IList>

Wraps a function that determines which of the groups belonging to the hub described by the HubDescriptor the client should be allowed to rejoin. By default, clients will rejoin all the groups they were in prior to reconnecting.

Protected Methods

Method Description
OnAfterConnect ( IHub hub ) : void

This method is called after the connect components of any modules added later to the IHubPipeline are executed and after IHub.OnConnected is executed, if at all.

OnAfterDisconnect ( IHub hub, bool stopCalled ) : void

This method is called after the disconnect components of any modules added later to the IHubPipeline are executed and after IHub.OnDisconnected(bool) is executed, if at all.

OnAfterIncoming ( object result, IHubIncomingInvokerContext context ) : object

This method is called after the incoming components of any modules added later to the IHubPipeline and the server-side hub method have completed execution.

OnAfterOutgoing ( IHubOutgoingInvokerContext context ) : void

This method is called after the outgoing components of any modules added later to the IHubPipeline are executed. This does not mean that all the clients have received the hub method invocation, but it does indicate indicate a hub invocation message has successfully been published to a message bus.

OnAfterReconnect ( IHub hub ) : void

This method is called after the reconnect components of any modules added later to the IHubPipeline are executed and after IHub.OnReconnected is executed, if at all.

OnBeforeAuthorizeConnect ( HubDescriptor hubDescriptor, HttpRequest request ) : bool

This method is called before the AuthorizeConnect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules will not run and the client will not be allowed to subscribe to client-side invocations of methods belonging to the hub defined by the HubDescriptor.

OnBeforeConnect ( IHub hub ) : bool

This method is called before the connect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the IHub.OnConnected method will not be run.

OnBeforeDisconnect ( IHub hub, bool stopCalled ) : bool

This method is called before the disconnect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the IHub.OnDisconnected(bool) method will not be run.

OnBeforeIncoming ( IHubIncomingInvokerContext context ) : bool

This method is called before the incoming components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the server-side hub method invocation will not be executed. Even if a client has not been authorized to connect to a hub, it will still be authorized to invoke server-side methods on that hub unless it is prevented in IHubPipelineModule.BuildIncoming by not executing the invoke parameter or prevented in HubPipelineModule.OnBeforeIncoming by returning false.

OnBeforeOutgoing ( IHubOutgoingInvokerContext context ) : bool

This method is called before the outgoing components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the client-side hub method invocation(s) will not be executed.

OnBeforeReconnect ( IHub hub ) : bool

This method is called before the reconnect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the IHub.OnReconnected method will not be run.

OnIncomingError ( ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext ) : void

This is called when an uncaught exception is thrown by a server-side hub method or the incoming component of a module added later to the IHubPipeline. Observing the exception using this method will not prevent it from bubbling up to other modules.

Method Details

BuildAuthorizeConnect() public method

Wraps a function to be called before a client subscribes to signals belonging to the hub described by the HubDescriptor. By default, the AuthorizeModule will look for attributes on the IHub to help determine if the client is authorized to subscribe to method invocations for the described hub. The function returns true if the client is authorized to subscribe to client-side hub method invocations; false, otherwise.
public BuildAuthorizeConnect ( Func authorizeConnect ) : Func
authorizeConnect Func /// A function that dictates whether or not the client is authorized to connect to the described Hub. ///
return Func

BuildConnect() public method

Wraps a function that is called when a client connects to the HubDispatcher for each IHub the client connects to. By default, this results in the IHub's OnConnected method being invoked.
public BuildConnect ( Task>.Func connect ) : Task>.Func
connect Task>.Func A function to be called when a client connects to a hub.
return Task>.Func

BuildDisconnect() public method

Wraps a function that is called when a client disconnects from the HubDispatcher for each IHub the client was connected to. By default, this results in the IHub's OnDisconnected method being invoked.
public BuildDisconnect ( Func disconnect ) : Func
disconnect Func /// A task-returning function to be called when a client disconnects from a hub. /// This function takes two parameters: /// 1. The is being disconnected from. /// 2. A boolean, stopCalled, that is true if stop was called on the client and false if the client timed out. /// Timeouts can be caused by clients reconnecting to another SignalR server in scaleout. ///
return Func

BuildIncoming() public method

Wraps a function that invokes a server-side hub method. Even if a client has not been authorized to connect to a hub, it will still be authorized to invoke server-side methods on that hub unless it is prevented in IHubPipelineModule.BuildIncoming by not executing the invoke parameter.
public BuildIncoming ( Func invoke ) : Task>.Func
invoke Func A function that invokes a server-side hub method.
return Task>.Func

BuildOutgoing() public method

Wraps a function that invokes a client-side hub method.
public BuildOutgoing ( Task>.Func send ) : Task>.Func
send Task>.Func A function that invokes a client-side hub method.
return Task>.Func

BuildReconnect() public method

Wraps a function that is called when a client reconnects to the HubDispatcher for each IHub the client connects to. By default, this results in the IHub's OnReconnected method being invoked.
public BuildReconnect ( Task>.Func reconnect ) : Task>.Func
reconnect Task>.Func A function to be called when a client reconnects to a hub.
return Task>.Func

BuildRejoiningGroups() public method

Wraps a function that determines which of the groups belonging to the hub described by the HubDescriptor the client should be allowed to rejoin. By default, clients will rejoin all the groups they were in prior to reconnecting.
public BuildRejoiningGroups ( Func rejoiningGroups ) : Func,IList>
rejoiningGroups Func A function that determines which groups the client should be allowed to rejoin.
return Func,IList>

OnAfterConnect() protected method

This method is called after the connect components of any modules added later to the IHubPipeline are executed and after IHub.OnConnected is executed, if at all.
protected OnAfterConnect ( IHub hub ) : void
hub IHub The hub the client has connected to.
return void

OnAfterDisconnect() protected method

This method is called after the disconnect components of any modules added later to the IHubPipeline are executed and after IHub.OnDisconnected(bool) is executed, if at all.
protected OnAfterDisconnect ( IHub hub, bool stopCalled ) : void
hub IHub The hub the client has disconnected from.
stopCalled bool /// true, if stop was called on the client closing the connection gracefully; /// false, if the client timed out. Timeouts can be caused by clients reconnecting to another SignalR server in scaleout. ///
return void

OnAfterIncoming() protected method

This method is called after the incoming components of any modules added later to the IHubPipeline and the server-side hub method have completed execution.
protected OnAfterIncoming ( object result, IHubIncomingInvokerContext context ) : object
result object The return value of the server-side hub method
context IHubIncomingInvokerContext A description of the server-side hub method invocation.
return object

OnAfterOutgoing() protected method

This method is called after the outgoing components of any modules added later to the IHubPipeline are executed. This does not mean that all the clients have received the hub method invocation, but it does indicate indicate a hub invocation message has successfully been published to a message bus.
protected OnAfterOutgoing ( IHubOutgoingInvokerContext context ) : void
context IHubOutgoingInvokerContext A description of the client-side hub method invocation.
return void

OnAfterReconnect() protected method

This method is called after the reconnect components of any modules added later to the IHubPipeline are executed and after IHub.OnReconnected is executed, if at all.
protected OnAfterReconnect ( IHub hub ) : void
hub IHub The hub the client has reconnected to.
return void

OnBeforeAuthorizeConnect() protected method

This method is called before the AuthorizeConnect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules will not run and the client will not be allowed to subscribe to client-side invocations of methods belonging to the hub defined by the HubDescriptor.
protected OnBeforeAuthorizeConnect ( HubDescriptor hubDescriptor, HttpRequest request ) : bool
hubDescriptor HubDescriptor A description of the hub the client is trying to subscribe to.
request HttpRequest The connect request made by the client trying to subscribe to the hub.
return bool

OnBeforeConnect() protected method

This method is called before the connect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the IHub.OnConnected method will not be run.
protected OnBeforeConnect ( IHub hub ) : bool
hub IHub The hub the client has connected to.
return bool

OnBeforeDisconnect() protected method

This method is called before the disconnect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the IHub.OnDisconnected(bool) method will not be run.
protected OnBeforeDisconnect ( IHub hub, bool stopCalled ) : bool
hub IHub The hub the client has disconnected from.
stopCalled bool /// true, if stop was called on the client closing the connection gracefully; /// false, if the client timed out. Timeouts can be caused by clients reconnecting to another SignalR server in scaleout. ///
return bool

OnBeforeIncoming() protected method

This method is called before the incoming components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the server-side hub method invocation will not be executed. Even if a client has not been authorized to connect to a hub, it will still be authorized to invoke server-side methods on that hub unless it is prevented in IHubPipelineModule.BuildIncoming by not executing the invoke parameter or prevented in HubPipelineModule.OnBeforeIncoming by returning false.
protected OnBeforeIncoming ( IHubIncomingInvokerContext context ) : bool
context IHubIncomingInvokerContext A description of the server-side hub method invocation.
return bool

OnBeforeOutgoing() protected method

This method is called before the outgoing components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the client-side hub method invocation(s) will not be executed.
protected OnBeforeOutgoing ( IHubOutgoingInvokerContext context ) : bool
context IHubOutgoingInvokerContext A description of the client-side hub method invocation.
return bool

OnBeforeReconnect() protected method

This method is called before the reconnect components of any modules added later to the IHubPipeline are executed. If this returns false, then those later-added modules and the IHub.OnReconnected method will not be run.
protected OnBeforeReconnect ( IHub hub ) : bool
hub IHub The hub the client has reconnected to.
return bool

OnIncomingError() protected method

This is called when an uncaught exception is thrown by a server-side hub method or the incoming component of a module added later to the IHubPipeline. Observing the exception using this method will not prevent it from bubbling up to other modules.
protected OnIncomingError ( ExceptionContext exceptionContext, IHubIncomingInvokerContext invokerContext ) : void
exceptionContext ExceptionContext /// Represents the exception that was thrown during the server-side invocation. /// It is possible to change the error or set a result using this context. ///
invokerContext IHubIncomingInvokerContext A description of the server-side hub method invocation.
return void