Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

angel-dart-archive/eventsource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eventsource

Server-sent Events (SSE) plugin for Angel.

Installation

In your pubspec.yaml:

dependencies:
    angel_eventsource: ^1.0.0

Usage

SSE and WebSockets are somewhat similar in that they allow pushing of events from server to client. SSE is not bi-directional, but the same abstractions used for WebSockets can be applied to SSE easily.

For this reason, the AngelEventSourcePublisher class is a simple adapter that hands control of SSE requests to an existing AngelWebSocket driver.

So, using this is pretty straightforward. You can dispatch events via WebSocket as per usual, and have them propagated to SSE clients as well.

var app = new Angel();
var ws = new AngelWebSocket(app);
var events = new AngelEventSourcePublisher(ws);

await app.configure(ws.configureServer);

app.all('/ws', ws.handleRequest);
app.get('/events', events.handleRequest);

Releases

No releases published

Packages

No packages published

Languages