AngelWebSocket class

Broadcasts events from HookedServices, and handles incoming WebSocketActions.

Constructors

AngelWebSocket(Angel app, {bool sendErrors = false, bool allowClientParams = false, bool allowAuth = true, StreamChannel<WebSocketEvent>? synchronizationChannel, WebSocketResponseSerializer? serializer, Function? deserializer, List<String> allowedOrigins = const [], List<String> allowedProtocols = const []})

Properties

allowAuth bool
If true, then clients can authenticate their WebSockets by sending a valid JWT.
final
allowClientParams bool
If this is not true, then all client-side service parameters will be discarded, other than params['query'].
final
allowedOrigins List<String>
An optional whitelist of allowed client origins, or null.
final
allowedProtocols List<String>
An optional whitelist of allowed client protocols, or null.
final
app → Angel
final
clients List<WebSocketContext>
A list of clients currently connected to this server via WebSockets.
no setter
deserializer Function?
Deserializes data from WebSockets.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
onAction Stream<WebSocketAction>
Fired on any WebSocketAction.
no setter
onConnection Stream<WebSocketContext>
Fired on incoming connections.
no setter
onData Stream
Fired whenever a WebSocket sends data.
no setter
onDisconnection Stream<WebSocketContext>
Fired when a user disconnects.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sendErrors bool
Send error information across WebSockets, without including debug information..
final
serializer WebSocketResponseSerializer?
Serializes data to WebSockets.
getter/setter pair
servicesAlreadyWired List<String>
Services that have already been hooked to fire socket events.
no setter
synchronizationChannel → StreamChannel<WebSocketEvent>?
Used to notify other nodes of an event's firing. Good for scaled applications.
final

Methods

batchEvent(WebSocketEvent event, {dynamic filter(WebSocketContext socket)?, bool notify = true}) Future<void>
Slates an event to be dispatched.
catchError(dynamic e, StackTrace st, WebSocketContext socket) → void
configureServer(Angel app) Future
Configures an Angel instance to listen for WebSocket connections.
getBatchedEvents() Future<List<WebSocketEvent>>
Returns a list of events yet to be sent.
handleAction(WebSocketAction action, WebSocketContext socket) Future
Responds to an incoming action on a WebSocket.
handleAuth(WebSocketAction action, WebSocketContext socket) Future
Authenticates a WebSocketContext.
handleClient(WebSocketContext socket) Future<void>
Handles an incoming WebSocketContext.
handleConnect(WebSocketContext socket) Future
Runs before firing onConnection.
handleData(WebSocketContext socket, dynamic data) → dynamic
Handles incoming data from a WebSocket.
handleRequest(RequestContext req, ResponseContext res) Future<bool>
Handles an incoming HTTP request.
hookupService(Pattern path, HookedService<dynamic, dynamic, Service> service) → dynamic
Hooks a service up to have its events broadcasted.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
serviceHook(String path) FutureOr Function(HookedServiceEvent<dynamic, dynamic, Service> e)
toString() String
A string representation of this object.
inherited
transformEvent(HookedServiceEvent<dynamic, dynamic, Service> event) Future<WebSocketEvent>
Transforms a HookedServiceEvent, so that it can be broadcasted.
wireAllServices(Angel app) → void
Hooks any HookedServices that are not being broadcasted yet.

Operators

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