HubConnection class

Represents a connection to a SignalR Hub

Constructors

HubConnection(IConnection connection, Logger? logger, IHubProtocol protocol, {IRetryPolicy? reconnectPolicy})

Properties

baseUrl String?
Indicates the url of the {@link HubConnection} to the server.
getter/setter pair
connectionId String?
Represents the connection id of the {@link HubConnection} on the server. The connection id will be null when the connection is either in the disconnected state or if the negotiation step was skipped.
no setter
hashCode int
The hash code for this object.
no setterinherited
keepAliveIntervalInMilliseconds int
Default interval at which to ping the server.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serverTimeoutInMilliseconds int
The server timeout in milliseconds.
getter/setter pair
state HubConnectionState?
Indicates the state of the {@link HubConnection} to the server.
no setter
stateStream Stream<HubConnectionState>
Emits upon changes of the {@link HubConnectionState}.
no setter

Methods

invoke(String methodName, {List<Object>? args}) Future<Object?>
Invokes a hub method on the server using the specified name and arguments.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
off(String methodName, {MethodInvocationFunc? method}) → void
Removes the specified handler for the specified hub method.
on(String methodName, MethodInvocationFunc newMethod) → void
Registers a handler that will be invoked when the hub method with the specified method name is invoked.
onclose(ClosedCallback callback) → void
Registers a handler that will be invoked when the connection is closed.
onreconnected(ReconnectedCallback callback) → dynamic
Registers a handler that will be invoked when the connection successfully reconnects.
onreconnecting(ReconnectingCallback callback) → dynamic
Registers a handler that will be invoked when the connection starts reconnecting.
send(String methodName, {List<Object>? args}) Future<void>
Invokes a hub method on the server using the specified name and arguments. Does not wait for a response from the receiver.
start() Future<void>?
Starts the connection.
stop() Future<void>
Stops the connection.
stream(String methodName, List<Object> args) Stream<Object?>
Invokes a streaming hub method on the server using the specified name and arguments.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

create(IConnection connection, Logger? logger, IHubProtocol protocol, {IRetryPolicy? reconnectPolicy}) HubConnection