sync -> streamchannel
This commit is contained in:
parent
7092cb764e
commit
b767b3583f
3 changed files with 11 additions and 18 deletions
|
@ -1,3 +1,6 @@
|
|||
# 2.0.0-alpha.7
|
||||
* Replace `WebSocketSynchronizer` with `StreamChannel<WebSocketEvent>`.
|
||||
|
||||
# 2.0.0-alpha.6
|
||||
* Explicit import of `import 'package:http/io_client.dart' as http;`
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class AngelWebSocket {
|
|||
new List.unmodifiable(_servicesAlreadyWired);
|
||||
|
||||
/// Used to notify other nodes of an event's firing. Good for scaled applications.
|
||||
final WebSocketSynchronizer synchronizer;
|
||||
final StreamChannel<WebSocketEvent> synchronizationChannel;
|
||||
|
||||
/// Fired on any [WebSocketAction].
|
||||
Stream<WebSocketAction> get onAction => _onAction.stream;
|
||||
|
@ -77,7 +77,7 @@ class AngelWebSocket {
|
|||
{this.sendErrors: false,
|
||||
this.allowClientParams: false,
|
||||
this.allowAuth: true,
|
||||
this.synchronizer,
|
||||
this.synchronizationChannel,
|
||||
this.serializer,
|
||||
this.deserializer}) {
|
||||
if (serializer == null) serializer = json.encode;
|
||||
|
@ -116,8 +116,8 @@ class AngelWebSocket {
|
|||
}
|
||||
});
|
||||
|
||||
if (synchronizer != null && notify != false)
|
||||
synchronizer.notifyOthers(event);
|
||||
if (synchronizationChannel != null && notify != false)
|
||||
synchronizationChannel.sink.add(event);
|
||||
}
|
||||
|
||||
/// Returns a list of events yet to be sent.
|
||||
|
@ -326,11 +326,11 @@ class AngelWebSocket {
|
|||
wireAllServices(app);
|
||||
});
|
||||
|
||||
if (synchronizer != null) {
|
||||
synchronizer.stream.listen((e) => batchEvent(e, notify: false));
|
||||
if (synchronizationChannel != null) {
|
||||
synchronizationChannel.stream.listen((e) => batchEvent(e, notify: false));
|
||||
}
|
||||
|
||||
app.shutdownHooks.add((_) => synchronizer?.close());
|
||||
app.shutdownHooks.add((_) => synchronizationChannel?.sink?.close());
|
||||
}
|
||||
|
||||
/// Handles an incoming [WebSocketContext].
|
||||
|
@ -375,13 +375,3 @@ class AngelWebSocket {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Notifies other nodes of outgoing WWebSocket events, and listens for
|
||||
/// notifications from other nodes.
|
||||
abstract class WebSocketSynchronizer {
|
||||
Stream<WebSocketEvent> get stream;
|
||||
|
||||
Future close() => new Future.value();
|
||||
|
||||
void notifyOthers(WebSocketEvent e);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ name: angel_websocket
|
|||
description: WebSocket plugin for Angel.
|
||||
environment:
|
||||
sdk: ">=2.0.0-dev <3.0.0"
|
||||
version: 2.0.0-alpha.6
|
||||
version: 2.0.0-alpha.7
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/angel_websocket
|
||||
dependencies:
|
||||
|
|
Loading…
Reference in a new issue