OmnyShellHubService class
The OmnyShell Hub as an omnyhub omnyhub.Service, so its broker can be
hosted on any omnyhub.OmnyHub listener instead of owning one.
This is what lets a different Hub — an OmnyServer Hub, say — also serve OmnyShell nodes: mount this at a path and OmnyShell traffic is routed to it while the host keeps its own surfaces on the same port and certificate.
// On an OmnyServer (or any omnyhub) Hub:
await hub.registerService(OmnyShellHubService(broker, mount: '/shell'));
// Nodes then dial wss://host:8443/shell
HubBroker is transport-agnostic — it is driven by accepting connections —
so this class is only an adapter: omnyhub hands over a raw
omnyhub.Connection, and FrameConnection wraps it in OmnyShell's frame
codec.
The broker must own the socket un-intercepted. OmnyShell authenticates
in band, after the upgrade: the Hub speaks first with a challenge hello,
and the peer answers with an auth.request. So this route must not be given
an omnyhub.ConnectionAuthenticator — one would consume the very frames the
broker is waiting for. Note that on omnyhub a route's null authenticator
means inherit the hub-wide one, not none: a host hub that sets a hub-wide
connection authenticator must ensure it does not reach this mount.
Constructors
- OmnyShellHubService(HubBroker broker, {String name = 'omnyshell', String mount = '/', FrameCodec codecFactory()?, bool ownsBroker = true})
-
Mounts
brokeras a service.
Properties
- broker → HubBroker
-
The broker that authenticates, authorizes and relays.
final
- codecFactory → FrameCodec Function()?
-
Builds the frame codec for each accepted connection.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- mount → String
-
finalinherited
- name → String
-
finalinherited
- ownsBroker → bool
-
Whether this service owns broker's lifecycle.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
handle(
HubRequest request) → Future< HubResponse> - A plain HTTP request on the mount: this is a WebSocket endpoint, so answer with a small status document rather than an upgrade.
-
handleConnection(
Connection connection, HubRequest request) → void -
Handles an upgraded WebSocket
connectionwhose upgraderequestmatched this service. Services that do not serve WebSockets should close the connection. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
) → Future< void> -
Starts the service (open resources, connect to backends, ...). Called by
the hub on
OmnyHub.startor when registered into a running hub. -
stop(
) → Future< void> - Stops the service and releases its resources.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited