From bdb9ad4fcd78f7a6124d66608e4ce8227d74bdf3 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Sat, 3 Sep 2016 07:33:59 -0400 Subject: [PATCH] Controller is missing??? --- lib/browser.dart | 31 ++++++++++++++++++++++++------- lib/server.dart | 2 -- pubspec.yaml | 4 ++-- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/browser.dart b/lib/browser.dart index d9e89109..56d1fea2 100644 --- a/lib/browser.dart +++ b/lib/browser.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'dart:html'; import 'package:angel_client/angel_client.dart'; import 'package:angel_websocket/angel_websocket.dart'; +export 'package:angel_websocket/angel_websocket.dart'; class WebSocketClient extends Angel { WebSocket _socket; @@ -97,8 +98,9 @@ class _WebSocketServiceTransformer var _stream = new StreamController(); stream.listen((WebSocketEvent e) { - if (_outputType != null && e.eventName != "error") + /* if (_outputType != null && e.eventName != "error") e.data = god.deserialize(god.serialize(e.data), outputType: _outputType); + */ _stream.add(e); }); @@ -154,40 +156,55 @@ class WebSocketService extends Service { _transformer = new _WebSocketServiceTransformer.base(this._outputType); } + _serialize(WebSocketAction action) { + var data = { + "id": action.id, + "eventName": action.eventName + }; + + if (action.data != null) + data["data"] = action.data; + + if (action.params != null) + data["params"] = action.params; + + return JSON.encode(data); + } + @override Future index([Map params]) async { - connection.send(god.serialize( + connection.send(_serialize( new WebSocketAction(eventName: "$_path::index", params: params))); return null; } @override Future read(id, [Map params]) async { - connection.send(god.serialize(new WebSocketAction( + connection.send(_serialize(new WebSocketAction( eventName: "$_path::read", id: id, params: params))); } @override Future create(data, [Map params]) async { - connection.send(god.serialize(new WebSocketAction( + connection.send(_serialize(new WebSocketAction( eventName: "$_path::create", data: data, params: params))); } @override Future modify(id, data, [Map params]) async { - connection.send(god.serialize(new WebSocketAction( + connection.send(_serialize(new WebSocketAction( eventName: "$_path::modify", id: id, data: data, params: params))); } @override Future update(id, data, [Map params]) async { - connection.send(god.serialize(new WebSocketAction( + connection.send(_serialize(new WebSocketAction( eventName: "$_path::update", id: id, data: data, params: params))); } @override Future remove(id, [Map params]) async { - connection.send(god.serialize(new WebSocketAction( + connection.send(_serialize(new WebSocketAction( eventName: "$_path::remove", id: id, params: params))); } } diff --git a/lib/server.dart b/lib/server.dart index 43c306e9..f52d0805 100644 --- a/lib/server.dart +++ b/lib/server.dart @@ -3,11 +3,9 @@ library angel_websocket.server; import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'dart:mirrors'; import 'package:angel_framework/angel_framework.dart'; import 'package:json_god/json_god.dart' as god; import 'package:merge_map/merge_map.dart'; -import 'package:uuid/uuid.dart'; import 'angel_websocket.dart'; part 'websocket_context.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index c8b5abde..b5e0a63a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: angel_websocket description: WebSocket plugin for Angel -version: 1.0.0-dev +version: 1.0.0-dev+1 author: thosakwe homepage: https://github.com/angel-dart/angel_websocket dependencies: @@ -11,4 +11,4 @@ dependencies: uuid: ">=0.5.3 <1.0.0" dev_dependencies: http: ">= 0.11.3 < 0.12.0" - test: ">= 0.12.13 < 0.13.0" \ No newline at end of file + test: ">= 0.12.13 < 0.13.0"