Updated package websocket

This commit is contained in:
thomashii 2021-03-08 00:18:07 +08:00
parent e1302d6a6a
commit 197c4034d3
4 changed files with 60 additions and 53 deletions

View file

@ -12,8 +12,8 @@
* Upgrade jael_preprocessor to 3.0.0
* Upgrade validate to 3.0.0
* Upgrade json_god to 3.0.0
* Upgrade angel_client to 3.0.0
* Upgrade angel_client to 3.0.0 (todo)
* Upgrade angel_websocket to 3.0.0 (todo)
* Upgrade test to 3.0.0 (todo)
* Upgrade angel_jael to 3.0.0 (todo)

View file

@ -2,20 +2,36 @@ author: Tobe O <thosakwe@gmail.com>
description: Testing utility library for the Angel framework. Use with package:test.
homepage: https://github.com/angel-dart/test.git
name: angel_test
version: 2.0.1
version: 3.0.0
publish_to: none
environment:
sdk: ">=2.10.0 <2.12.0"
sdk: ">=2.10.0 <3.0.0"
dependencies:
angel_client: # ^2.0.0
path: ../client
angel_framework: # ^2.0.0-alpha
path: ../framework
angel_http_exception: #^1.0.0
path: ../http_exception
angel_validate: # ^2.0.0
path: ../validate
angel_websocket: # ^2.0.0
path: ../websocket
angel_client:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/client
angel_framework:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/framework
angel_http_exception:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/http_exception
angel_validate:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/validate
angel_websocket:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/websocket
http: ^0.12.0
matcher: ^0.12.0
mock_request: ^1.0.0

View file

@ -91,8 +91,8 @@ class AngelWebSocket {
this.deserializer,
this.allowedOrigins,
this.allowedProtocols}) {
if (serializer == null) serializer = json.encode;
if (deserializer == null) deserializer = (params) => params;
serializer ??= json.encode;
deserializer ??= (params) => params;
}
HookedServiceEventListener serviceHook(String path) {
@ -100,16 +100,17 @@ class AngelWebSocket {
if (e.params != null && e.params['broadcast'] == false) return;
var event = await transformEvent(e);
event.eventName = "$path::${event.eventName}";
event.eventName = '$path::${event.eventName}';
_filter(WebSocketContext socket) {
if (e.service.configuration.containsKey('ws:filter'))
dynamic _filter(WebSocketContext socket) {
if (e.service.configuration.containsKey('ws:filter')) {
return e.service.configuration['ws:filter'](e, socket);
else if (e.params != null && e.params.containsKey('ws:filter'))
} else if (e.params != null && e.params.containsKey('ws:filter')) {
return e.params['ws:filter'](e, socket);
else
} else {
return true;
}
}
await batchEvent(event, filter: _filter);
};
@ -236,8 +237,10 @@ class AngelWebSocket {
}
/// Hooks a service up to have its events broadcasted.
hookupService(Pattern _path, HookedService service) {
String path = _path.toString();
dynamic hookupService(Pattern _path, HookedService service) {
var path = _path.toString();
// TODO: Relook at this code
service.after(
[
HookedServiceEvent.created,

View file

@ -7,22 +7,16 @@ author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_websocket
publish_to: none
dependencies:
angel_auth: ^3.0.0
angel_client: ^3.0.0
angel_framework: ^3.0.0
angel_http_exception: ^2.0.0
http: ">=0.11.0 <0.13.0"
merge_map: ^1.0.0
meta: ^1.0.0
stream_channel: ^2.0.0
web_socket_channel: ^1.0.0
dev_dependencies:
angel_container: ^2.0.0
angel_model: ^2.0.0
# logging: ^0.11.0
pedantic: ^1.0.0
test: ^1.15.7
dependency_overrides:
angel_auth:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/auth
angel_client:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/client
angel_framework:
git:
url: https://github.com/dukefirehawk/angel.git
@ -33,6 +27,12 @@ dependency_overrides:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/http_exception
http: ^0.13.0
merge_map: ^1.0.0
meta: ^1.0.0
stream_channel: ^2.0.0
web_socket_channel: ^2.0.0
dev_dependencies:
angel_container:
git:
url: https://github.com/dukefirehawk/angel.git
@ -43,19 +43,7 @@ dependency_overrides:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/model
angel_route:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/route
angel_auth:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/auth
angel_client:
git:
url: https://github.com/dukefirehawk/angel.git
ref: sdk-2.12.x
path: packages/angel_client
# logging: ^0.11.0
pedantic: ^1.0.0
test: ^1.15.7