This commit is contained in:
thosakwe 2017-02-12 15:06:54 -05:00
parent fc137dac31
commit cfae7cf99f
5 changed files with 13 additions and 8 deletions

View file

@ -1,5 +1,5 @@
# angel_websocket # angel_websocket
[![1.0.0-dev+10](https://img.shields.io/badge/pub-1.0.0--dev+10-red.svg)](https://pub.dartlang.org/packages/angel_websocket) [![1.0.0](https://img.shields.io/badge/pub-1.0.0-brightgreen.svg)](https://pub.dartlang.org/packages/angel_websocket)
[![build status](https://travis-ci.org/angel-dart/websocket.svg)](https://travis-ci.org/angel-dart/websocket) [![build status](https://travis-ci.org/angel-dart/websocket.svg)](https://travis-ci.org/angel-dart/websocket)
WebSocket plugin for Angel. WebSocket plugin for Angel.

View file

@ -234,7 +234,7 @@ class BaseWebSocketService extends Service {
} }
@override @override
Future<List> index([Map params]) async { Future index([Map params]) async {
socket.sink.add(serialize(new WebSocketAction( socket.sink.add(serialize(new WebSocketAction(
eventName: '$path::${ACTION_INDEX}', params: params ?? {}))); eventName: '$path::${ACTION_INDEX}', params: params ?? {})));
return null; return null;

View file

@ -38,13 +38,14 @@ class WebSockets extends BaseWebSocketClient {
WebSocketsService service<T>(String path, WebSocketsService service<T>(String path,
{Type type, AngelDeserializer deserializer}) { {Type type, AngelDeserializer deserializer}) {
String uri = path.replaceAll(_straySlashes, ''); String uri = path.replaceAll(_straySlashes, '');
return new WebSocketsService(socket, this, uri, null); return new WebSocketsService(socket, this, uri, deserializer: deserializer);
} }
} }
class WebSocketsService extends BaseWebSocketService { class WebSocketsService extends BaseWebSocketService {
final Type type; final Type type;
WebSocketsService(WebSocketChannel socket, Angel app, String uri, this.type) WebSocketsService(WebSocketChannel socket, Angel app, String uri,
: super(socket, app, uri); {this.type, AngelDeserializer deserializer})
: super(socket, app, uri, deserializer: deserializer);
} }

View file

@ -91,7 +91,7 @@ class AngelWebSocket extends AngelPlugin {
if (result == true) { if (result == true) {
var serialized = event.toJson(); var serialized = event.toJson();
_printDebug('Batching this event: $serialized'); _printDebug('Batching this event: $serialized');
print('Serialized: ' + JSON.encode(serialized)); // print('Serialized: ' + JSON.encode(serialized));
client.io.add(god.serialize(event.toJson())); client.io.add(god.serialize(event.toJson()));
} }
}); });
@ -117,7 +117,11 @@ class AngelWebSocket extends AngelPlugin {
var params = mergeMap([ var params = mergeMap([
god.deserializeDatum(action.params), god.deserializeDatum(action.params),
{"provider": Providers.WEBSOCKET} {
"provider": Providers.WEBSOCKET,
'__requestctx': socket.request,
'__responsectx': socket.response
}
]); ]);
try { try {

View file

@ -2,7 +2,7 @@ name: angel_websocket
description: WebSocket plugin for Angel description: WebSocket plugin for Angel
environment: environment:
sdk: ">=1.19.0" sdk: ">=1.19.0"
version: 1.0.0-dev+10 version: 1.0.0
author: Tobe O <thosakwe@gmail.com> author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/angel_websocket homepage: https://github.com/angel-dart/angel_websocket
dependencies: dependencies: