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

套件詳情v0.2.1

signalr_flutter

一個用於 .net SignalR 客戶端的 Flutter 插件。此客戶端適用於 ASP.Net SignalR,而非 .Net Core SignalR。

AndroidiOS
近 30 天下載
185
喜歡數
83
Pub 分數
150

安裝套件

flutter pub add signalr_flutter

套件介紹

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

signalr_flutter 是一個 Flutter 插件,可實現與 ASP.NET SignalR 伺服器的即時通訊。它支援 Flutter 應用與基於 .NET 的 SignalR 後端之間的雙向訊息傳遞,具備連接管理、事件處理及自動重連等功能。專為 ASP.NET SignalR(非 .NET Core)設計,可無縫整合至 Android 與 iOS 應用中。此外,該插件簡化了在 Flutter 應用中實作即時更新、聊天系統、通知與協作工具的過程。

適用情境

  • 即時聊天應用
  • 即時儀表板更新
  • 推送通知
  • 協作編輯工具
  • 物聯網裝置監控

主要特色

  • 僅支援 ASP.NET SignalR
  • 雙向通訊
  • 自動重連
  • 事件驅動的消息處理
  • 輕量且平台無關

適合對象

  • 使用 ASP.NET SignalR 的開發人員
  • 需要即時資料同步的應用程式
  • 需要即時更新的行動應用程式
  • 建構互動體驗的團隊

使用建議

  • 與 .NET Core SignalR 不相容
  • 需要伺服器端的 ASP.NET SignalR 設定
  • 僅限 Android 和 iOS 平台

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

signalr_flutter

A flutter plugin for .net SignalR client.

Usage

First of all, Initialize SignalR and connect to your server.

SignalR signalR = SignalR(
        '<Your server url here>',
        "<Your hub name here>",
        hubMethods: ["<Your Hub Method Names>"]
        statusChangeCallback: (status) => print(status),
        hubCallback: (methodName, message) => print('MethodName = $methodName, Message = $message'));
signalR.connect();

Here statusChangeCallback will get called whenever connection status with server changes.

hubCallback will receive calls from the server if you subscribe to any hub method. You can do that with hubMethods.

hubMethods are the hub method names you want to subscribe.

There is a headers parameters also which takes a Map<String, String>.

You can also invoke any server method.

signalR.invokeMethod("<Your method name here>", arguments: ["argument1", "argument2"]);

If you are trying to connect with a HTTP url, then you need to add the following lines to the manifest of your android project.

<application
        android:usesCleartextTraffic="true">
</application>

This is because of the Network Security Config.

R8 may strip away some SignalR classes for the Android in Release Builds. Add the following line in your proguard-rules.pro file to solve this issue.

-keep class microsoft.aspnet.signalr.client.hubs.** { *; }

For more info check example.

Any issue or PR is always welcome.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。