Add onAuthenticated to server-side
This commit is contained in:
parent
66d3fb2e04
commit
8e8271f161
4 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
# 2.0.1
|
||||
* Add `reconnectOnClose` and `reconnectinterval` parameters in top-level `WebSockets` constructors.
|
||||
* Close `WebSocketExtraneousEventHandler`.
|
||||
* Add onAuthenticated to server-side.
|
||||
|
||||
# 2.0.0
|
||||
* Update to work with `client@2.0.0`.
|
||||
|
|
|
@ -223,6 +223,7 @@ class AngelWebSocket {
|
|||
socket.request
|
||||
..container.registerSingleton<AuthToken>(token)
|
||||
..container.registerSingleton(user, as: user.runtimeType as Type);
|
||||
socket._onAuthenticated.add(null);
|
||||
socket.send(authenticatedEvent,
|
||||
{'token': token.serialize(auth.hmac), 'data': user});
|
||||
} catch (e, st) {
|
||||
|
|
|
@ -18,6 +18,8 @@ class WebSocketContext {
|
|||
StreamController<WebSocketAction> _onAction =
|
||||
new StreamController<WebSocketAction>();
|
||||
|
||||
StreamController<void> _onAuthenticated = StreamController();
|
||||
|
||||
StreamController<Null> _onClose = new StreamController<Null>();
|
||||
|
||||
StreamController _onData = new StreamController();
|
||||
|
@ -25,6 +27,9 @@ class WebSocketContext {
|
|||
/// Fired on any [WebSocketAction];
|
||||
Stream<WebSocketAction> get onAction => _onAction.stream;
|
||||
|
||||
/// Fired when the user authenticates.
|
||||
Stream<void> get onAuthenticated => _onAuthenticated.stream;
|
||||
|
||||
/// Fired once the underlying [WebSocket] closes.
|
||||
Stream<Null> get onClose => _onClose.stream;
|
||||
|
||||
|
@ -37,6 +42,7 @@ class WebSocketContext {
|
|||
Future close() async {
|
||||
await channel.sink.close();
|
||||
_onAction.close();
|
||||
_onAuthenticated.close();
|
||||
_onData.close();
|
||||
_onClose.add(null);
|
||||
_onClose.close();
|
||||
|
|
|
@ -2,7 +2,7 @@ name: angel_websocket
|
|||
description: Support for using pkg:angel_client with WebSockets. Designed for Angel.
|
||||
environment:
|
||||
sdk: ">=2.0.0-dev <3.0.0"
|
||||
version: 2.0.0
|
||||
version: 2.0.1
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/angel_websocket
|
||||
dependencies:
|
||||
|
|
Loading…
Reference in a new issue