HubConnection class
Represents a connection to a SignalR Hub.
Properties
server |
The server timeout in milliseconds. If this timeout elapses without receiving any messages from the server, the connection will be terminated with an error. The default timeout value is 30,000 milliseconds (30 seconds). |
Methods
invoke | Invokes a hub method on the server using the specified name and arguments. The Promise returned by this method resolves when the server indicates it has finished invoking the method. When the promise resolves, the server has finished invoking the method. If the server method returns a result, it is produced as the result of resolving the Promise. |
off | Removes all handlers for the specified hub method. |
off | Removes the specified handler for the specified hub method. You must pass the exact same Function instance as was previously passed to on. Passing a different instance (even if the function body is the same) will not remove the handler. |
on | Registers a handler that will be invoked when the hub method with the specified method name is invoked. |
onclose | Registers a handler that will be invoked when the connection is closed. |
send | Invokes a hub method on the server using the specified name and arguments. Does not wait for a response from the receiver. The Promise returned by this method resolves when the client has sent the invocation to the server. The server may still be processing the invocation. |
start | Starts the connection. |
stop | Stops the connection. |
stream | Invokes a streaming hub method on the server using the specified name and arguments. |
Property Details
serverTimeoutInMilliseconds
The server timeout in milliseconds. If this timeout elapses without receiving any messages from the server, the connection will be terminated with an error. The default timeout value is 30,000 milliseconds (30 seconds).
public serverTimeoutInMilliseconds: number
Property Value
Method Details
invoke
Invokes a hub method on the server using the specified name and arguments. The Promise returned by this method resolves when the server indicates it has finished invoking the method. When the promise resolves, the server has finished invoking the method. If the server method returns a result, it is produced as the result of resolving the Promise.
function invoke<T>(methodName: string, args: any[])
Parameters
Returns
off
Removes all handlers for the specified hub method.
function off(methodName: string)
Parameters
off
Removes the specified handler for the specified hub method. You must pass the exact same Function instance as was previously passed to on. Passing a different instance (even if the function body is the same) will not remove the handler.
function off(methodName: string, method: (args: any[]) => void)
Parameters
- method
- (args: any) => void[]
The handler to remove. This must be the same Function instance as the one passed to on.
on
Registers a handler that will be invoked when the hub method with the specified method name is invoked.
function on(methodName: string, newMethod: (args: any[]) => void)
Parameters
onclose
Registers a handler that will be invoked when the connection is closed.
function onclose(callback: (error?: Error) => void)
Parameters
send
Invokes a hub method on the server using the specified name and arguments. Does not wait for a response from the receiver. The Promise returned by this method resolves when the client has sent the invocation to the server. The server may still be processing the invocation.
function send(methodName: string, args: any[])
Parameters
Returns
start
stop
stream
Invokes a streaming hub method on the server using the specified name and arguments.
function stream<T>(methodName: string, args: any[])