1.0.5
This commit is contained in:
parent
6e1c1f4191
commit
e8f49bdf37
3 changed files with 26 additions and 7 deletions
24
README.md
24
README.md
|
@ -1,5 +1,5 @@
|
||||||
# angel_websocket
|
# 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)
|
[![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.
|
||||||
|
@ -56,8 +56,10 @@ class MyController extends WebSocketController {
|
||||||
|
|
||||||
// Dependency injection works, too..
|
// Dependency injection works, too..
|
||||||
@ExposeWs("read_message")
|
@ExposeWs("read_message")
|
||||||
void sendMessage(WebSocketContext socket, Db db) async {
|
void sendMessage(WebSocketContext socket, WebSocketAction, Db db) async {
|
||||||
socket.send("found_message", db.collection("messages").findOne(where.id("...")));
|
socket.send(
|
||||||
|
"found_message",
|
||||||
|
db.collection("messages").findOne(where.id(action.data['message_id'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event filtering
|
// 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**
|
**In the Browser**
|
||||||
|
|
||||||
```dart
|
```dart
|
||||||
|
@ -99,11 +113,11 @@ main() async {
|
||||||
**CLI Client**
|
**CLI Client**
|
||||||
|
|
||||||
```dart
|
```dart
|
||||||
import "package:angel_framework/angel_framework" as srv;
|
import "package:angel_framework/common.dart";
|
||||||
import "package:angel_websocket/io.dart";
|
import "package:angel_websocket/io.dart";
|
||||||
|
|
||||||
// You can include these in a shared file and access on both client and server
|
// 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;
|
int year;
|
||||||
String brand, make;
|
String brand, make;
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,12 @@ class AngelWebSocket extends AngelPlugin {
|
||||||
/// Hooks a service up to have its events broadcasted.
|
/// Hooks a service up to have its events broadcasted.
|
||||||
hookupService(Pattern _path, HookedService service) {
|
hookupService(Pattern _path, HookedService service) {
|
||||||
String path = _path.toString();
|
String path = _path.toString();
|
||||||
service.afterAll(serviceHook(path));
|
service.after([
|
||||||
|
HookedServiceEvent.CREATED,
|
||||||
|
HookedServiceEvent.MODIFIED,
|
||||||
|
HookedServiceEvent.UPDATED,
|
||||||
|
HookedServiceEvent.REMOVED
|
||||||
|
], serviceHook(path));
|
||||||
_servicesAlreadyWired.add(path);
|
_servicesAlreadyWired.add(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.4+3
|
version: 1.0.5
|
||||||
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:
|
||||||
|
|
Loading…
Reference in a new issue