패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.2.2

websocket_manager

Android 및 iOS용 Flutter 플러그인으로 WebSocket 연결을 지원합니다

30일 다운로드
49
좋아요
44
Pub 점수
40

패키지 설치

flutter pub add websocket_manager

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Android 및 iOS용으로 설계된 Flutter 플러그인으로, 원활한 WebSocket 연결을 가능하게 합니다. 앱과 서버 간 실시간 통신을 신뢰할 수 있고 효율적으로 유지할 수 있도록 하며 양방향 데이터 전송을 지원합니다. 연결 관리를 단순화하여 자동 재연결 및 메시지 처리를 포함하며, 실시간 업데이트, 채팅 애플리케이션, 실시간 알림에 적합합니다. 간편함과 성능을 고려해 제작되었으며, Flutter 프로젝트에 쉽게 통합됩니다.

사용 사례

  • 실시간 채팅 애플리케이션
  • 실시간 데이터 스트리밍
  • 푸시 알림 시스템
  • 사물인터넷 장치 통신
  • 온라인 게임 기능

주요 기능

  • 연결 끊김 시 자동 재연결
  • 양방향 메시지 교환
  • 연결 관리를 위한 간단한 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

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.