From e8f49bdf37cbef7655c0c6e2637dd67dbacf07fb Mon Sep 17 00:00:00 2001 From: thosakwe Date: Mon, 17 Apr 2017 08:37:17 -0400 Subject: [PATCH] 1.0.5 --- README.md | 24 +++++++++++++++++++----- lib/server.dart | 7 ++++++- pubspec.yaml | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7aec6abb..281c0bb9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # angel_websocket -[![1.0.4+3](https://img.shields.io/badge/pub-1.0.4+3-brightgreen.svg)](https://pub.dartlang.org/packages/angel_websocket) +[![1.0.5](https://img.shields.io/badge/pub-1.0.5+3-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) WebSocket plugin for Angel. @@ -56,8 +56,10 @@ class MyController extends WebSocketController { // Dependency injection works, too.. @ExposeWs("read_message") - void sendMessage(WebSocketContext socket, Db db) async { - socket.send("found_message", db.collection("messages").findOne(where.id("..."))); + void sendMessage(WebSocketContext socket, WebSocketAction, Db db) async { + socket.send( + "found_message", + db.collection("messages").findOne(where.id(action.data['message_id']))); } // Event filtering @@ -68,6 +70,18 @@ class MyController extends WebSocketController { } ``` +**Client Use** +This repo also provides two client libraries `browser` and `io` that extend the base +`angel_client` interface, and allow you to use a very similar API on the client to that of +the server. + +The provided clients also automatically try to reconnect their WebSockets when disconnected, +which means you can restart your development server without having to reload browser windows. + +They also provide streams of data that pump out filtered data as it comes in from the server. + +Clients can even perform authentication over WebSockets. + **In the Browser** ```dart @@ -99,11 +113,11 @@ main() async { **CLI Client** ```dart -import "package:angel_framework/angel_framework" as srv; +import "package:angel_framework/common.dart"; import "package:angel_websocket/io.dart"; // You can include these in a shared file and access on both client and server -class Car extends srv.Model { +class Car extends Model { int year; String brand, make; diff --git a/lib/server.dart b/lib/server.dart index 49da7ce4..876ddc47 100644 --- a/lib/server.dart +++ b/lib/server.dart @@ -230,7 +230,12 @@ class AngelWebSocket extends AngelPlugin { /// Hooks a service up to have its events broadcasted. hookupService(Pattern _path, HookedService service) { String path = _path.toString(); - service.afterAll(serviceHook(path)); + service.after([ + HookedServiceEvent.CREATED, + HookedServiceEvent.MODIFIED, + HookedServiceEvent.UPDATED, + HookedServiceEvent.REMOVED + ], serviceHook(path)); _servicesAlreadyWired.add(path); } diff --git a/pubspec.yaml b/pubspec.yaml index e93b8104..82d64578 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: angel_websocket description: WebSocket plugin for Angel. environment: sdk: ">=1.19.0" -version: 1.0.4+3 +version: 1.0.5 author: Tobe O homepage: https://github.com/angel-dart/angel_websocket dependencies: