搜尋套件、儲存庫與 APP 分類

套件詳情v0.4.0

eventsource

Server-Sent Events 的客戶端與伺服器端實作。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
595
喜歡數
30
Pub 分數
120

安裝套件

flutter pub add eventsource

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Dart 套件,提供伺服器端推送事件(SSE)的客戶端與伺服器端實作,支援從伺服器到客戶端的即時單向通訊。它支援透過 HTTP 順流傳輸事件,非常適合用於即時更新、通知與資料流。此套件相容所有主要平台,包含 Android、iOS、Web、macOS、Windows 與 Linux。它遵循 SSE 標準,支援事件 ID、重試間隔與自訂事件類型。實作輕量,可順暢整合至 Flutter 與 Dart 應用程式。

適用情境

  • 即時通知
  • 即時資料流
  • 伺服器端事件廣播
  • Web 應用中的狀態更新
  • 互動式儀表板
  • 日誌流

主要特色

  • 完整的 SSE 協議支援
  • 跨平台相容性
  • 事件 ID 和重試處理
  • 自定義事件類型支援
  • 輕便高效
  • 與 Flutter 的輕鬆整合

適合對象

  • 即時應用功能
  • 需要推播功能的後端服務
  • 需要低延遲更新的應用
  • 具有即時內容的網頁和行動應用程式
  • 使用 Dart/Flutter 開發全端應用的開發者

使用建議

  • 不適用於雙向通訊
  • 需要相容的伺服器實作
  • 僅限伺服器到客戶端的串流
  • 可能需要額外的設定來完成驗證
  • 最適合高頻率、低延遲的更新

原始 README

以下為關聯原始碼儲存庫的 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.

所屬分類

依賴

依賴清單 5 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。