FLUTTER ECOSYSTEM

stevenroose/dart-eventsource

伺服器端事件的客戶端與伺服器端實作。

dart-eventsource 專案封面
Stars
62
Forks
60
最近推送(UTC)
2024年7月19日
專案狀態
未封存
Steven Roose GitHub avatar
GITHUB User

Steven Roose ↗

"We publish our code so that our fellow Cypherpunks may practice and play with it. Our code is free for all to use, worldwide." - A Cypherpunk's Manifesto

second.techPortugal
語言Dart

此儲存庫發佈的套件

使用的依賴

依賴清單 6 項

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 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.

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.

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 for serving Server-Sent Events. This library provides an EventSourcePublisher that manages subscriptions, channels, encoding. We refer to documentation in the 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.