Skip to content

HubConnection

Represents the main entry point for a SignalR Core connection.

Fields:

Uri Uri

Gets the URI of the Hub endpoint.

ConnectionStates State

Gets the current state of this connection.

ITransport Transport

Gets the current active ITransport instance.

IProtocol Protocol

Gets the IProtocol implementation that will parse, encode, and decode messages.

Action<HubConnection, Uri, Uri> OnRedirected

Called when the connection is redirected to a new URI.

Action<HubConnection> OnConnected

Called when successfully connected to the hub.

Action<HubConnection, String> OnError

Called when an unexpected error happens and the connection is closed.

Action<HubConnection> OnClosed

Called when the connection is gracefully terminated.

Func<HubConnection, Message, Boolean> OnMessage

Called for every server-sent message. The return value determines further processing of the message.

Action<HubConnection, String> OnReconnecting

Called when the HubConnection starts its reconnection process after losing its underlying connection.

Action<HubConnection> OnReconnected

Called after a successful reconnection.

Action<HubConnection, ITransport, TransportEvents> OnTransportEvent

Called for transport-related events.

IAuthenticationProvider AuthenticationProvider

Gets or sets the IAuthenticationProvider implementation that will be used to authenticate the connection.

NegotiationResult NegotiationResult

Gets the negotiation response sent by the server.

HubOptions Options

Gets the HubOptions instance that were used to create the HubConnection.

Int32 RedirectCount

Gets how many times this connection has been redirected.

IRetryPolicy ReconnectPolicy

Gets or sets the reconnect policy that will be used when the underlying connection is lost. Defaults to null.

LoggingContext Context

Logging context of this HubConnection instance.

Methods:

Void StartConnect()

Initiates the connection process to the Hub.

Task<HubConnection> ConnectAsync()

Initiates an asynchronous connection to the Hub and returns a task representing the operation.

Void StartClose()

Begins the process to gracefully close the connection.

Task<HubConnection> CloseAsync()

Initiates an asynchronous close operation for the connection and returns a task representing the operation.

Send(String, Object[])

Invokes the specified method on the server without expecting a return value.

SendAsync(String, Object[])

Invokes the specified method on the server without expecting a return value.

SendAsync(String, CancellationToken, Object[])

Invokes the specified method on the server without expecting a return value, with an option to cancel.

Void On(String, Action)

Registers a callback to be invoked when the server calls the specified method with no parameters.

Void Remove(String)

Remove all event handlers for that subscribed with an On call.

Comments