パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.2.2

websocket_manager

Android および iOS 向けの Flutter プラグインで、WebSocket 接続をサポートしています

30日間ダウンロード
49
いいね数
44
Pub ポイント
40

パッケージをインストール

flutter pub add websocket_manager

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

AndroidおよびiOS向けに設計されたFlutterプラグインで、スムーズなWebSocket接続を可能にします。アプリとサーバー間のリアルタイム通信を確実かつ効率的に維持する方法を提供し、双方向データ転送をサポートしています。接続管理を簡素化しており、自動再接続やメッセージ処理を含んでおり、ライブアップデート、チャットアプリ、リアルタイム通知に最適です。シンプルさとパフォーマンスを意識して開発されており、Flutterプロジェクトへの統合がスムーズです。

用途

  • リアルタイムチャットアプリケーション
  • ライブデータストリーミング
  • プッシュ通知システム
  • IoTデバイス通信
  • オンラインゲーム機能

主な機能

  • 切断時に自動再接続
  • 双方向メッセージ交換
  • 接続管理のためのシンプルなAPI
  • JSON およびバイナリーメッセージのサポート
  • 組み込みエラー処理

適している対象

  • リアルタイムアプリを開発する開発者
  • 永続的なサーバー接続を必要とするアプリ
  • 低遅延通信が必要なプロジェクト

注意事項

  • AndroidおよびiOSプラットフォームに限定
  • 組み込みの暗号化なし(外部設定が必要)
  • 安定したネットワーク接続に依存しています

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。


NOTE: This repository is no longer maintained by ENGAPP. It was moved to be maintained by Kunlatek on the following link: https://github.com/kunlatek/flutter_websocket_manager_plugin

Any issue regarding this plugin should be reported there.


Websocket Manager

A Flutter plugin for Android and iOS supports websockets. This plugin is based on two different native libraries Starscream for iOS and okHttp for Android.

This plugin was created due to our necessity to maintain a WebSocket connection active in background while Flutter's WebSocket from cookbook doesn't keep alive while screen is locked or the application was in background.

Introduction

Websocket Manager doesn't manipulate websockets in Dart codes directly, instead, the plugin uses Platform Channel to expose Dart APIs that Flutter application can use to communicate with two very powerful websocket native libraries. Because of that, all credits belong to these libraries.

How to install

Android

You only need this configuration if your server doesn't have SSL/TLS

Since Android P http is blocked by default and there are many ways to configure. One way to configure is explicitly saying that you accept clear text for some host.

  • Create res/xml/network_security_config.xml with content:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">your_domain</domain>
    </domain-config>
</network-security-config>
  • Point to this file from your manifest (for bonus points add it only for the test manifest):
<application
    android:networkSecurityConfig="@xml/network_security_config"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
    <activity android:name=" (...)
</application>
iOS

Doesn't require any configuration

Example

int messageNum = 0;
// Configure WebSocket url
final socket = WebsocketManager('wss://echo.websocket.org');
// Listen to close message
socket.onClose((dynamic message) {
    print('close');
});
// Listen to server messages
socket.onMessage((dynamic message) {
    print('recv: $message');
    if messageNum == 10 {
        socket.close();
    } else {
        messageNum += 1;
        final String msg = '$messageNum: ${DateTime.now()}';
        print('send: $msg');
        socket.send(msg);
    }
});
// Connect to server
socket.connect();

Credits

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。