Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevenroose/dart-eventsource
A client and server implementation of Server-Side Events.
https://github.com/stevenroose/dart-eventsource
Last synced: 5 days ago
JSON representation
A client and server implementation of Server-Side Events.
- Host: GitHub
- URL: https://github.com/stevenroose/dart-eventsource
- Owner: stevenroose
- License: mit
- Created: 2016-11-27T20:33:10.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-19T09:49:43.000Z (6 months ago)
- Last Synced: 2025-01-12T13:06:50.614Z (12 days ago)
- Language: Dart
- Size: 29.3 KB
- Stars: 57
- Watchers: 7
- Forks: 52
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# eventsource
A library for using EventSource or Server-Sent Events (SSE).
Both client and server functionality is provided.This library implements the interface as described [here](https://html.spec.whatwg.org/multipage/comms.html#server-sent-events).
## Client usage
For more advanced usage, see the `example/` directory.
Creating a new EventSource client is as easy as a single call.
The http package is used under the hood, so wherever this package works, this library will also work.
Browser usage is slightly different.```dart
EventSource eventSource = await EventSource.connect("http://example.com/events");
// in browsers, you need to pass a http.BrowserClient:
EventSource eventSource = await EventSource.connect("http://example.com/events",
client: new http.BrowserClient());
```## Server usage
We recommend using [`shelf_eventsource`](https://pub.dartlang.org/packages/shelf_eventsource) for
serving Server-Sent Events.
This library provides an `EventSourcePublisher` that manages subscriptions, channels, encoding.
We refer to documentation in the [`shelf_eventsource`](https://pub.dartlang.org/packages/shelf_eventsource)
package for more information.This library also includes a server provider for `dart:io`'s `HttpServer` in `io_server.dart`.
However, it has some issues with data flushing that are yet to be resolved, so we recommend using
shelf instead.## Licensing
This project is available under the MIT license, as can be found in the LICENSE file.