andreabreu-me / FlutterWebRTCDataChannel

A Flutter plugin allowing apps to use WebRTC DataChannel to establish P2P connection and exchange text messages.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flutter WebRTC DataChannel plugin

This plugin allows Flutter apps to use WebRTC DataChannel to establish P2P connection and exchange text messages.

Install

Plugin dependency:

webrtc_data_channel: "^0.1.0"

WebRTC Android dependency:

rootProject.allprojects {
    repositories {
        maven {
            url  "https://google.bintray.com/webrtc"
        }
    }
}

dependencies {
    api 'org.webrtc:google-webrtc:1.0.22672'
}

WebRTC iOS dependency:

pod 'GoogleWebRTC', '1.1.22642'

Usage

import 'package:webrtc_data_channel/webrtc_data_channel.dart';

// create DataChannel and connect to room
WebRTCDataChannel _dataChannel = new WebRTCDataChannel();
_dataChannel.connect(_roomUrl, _roomId);

// listen for messages
_receivedMessages = _dataChannel.listenMessages()
        .listen((String message) {
            // handle message
        });

// send message
_dataChannel.sendMessage(message);

// disconnect from room
_dataChannel.disconnect();

Server setup

This plugin use webrtc/apprtc as room server and signal server, you can use https://appr.tc/ or deploy it yourself, I've a Docker image for it, piasy/apprtc-server.

Development setup

  • git clone https://github.com/Piasy/webrtc_data_channel
  • flutter create -t plugin webrtc_data_channel
  • cd webrtc_data_channel/example/ios && pod install

About

A Flutter plugin allowing apps to use WebRTC DataChannel to establish P2P connection and exchange text messages.

License:MIT License


Languages

Language:Objective-C 51.1%Language:Java 40.8%Language:Dart 6.4%Language:Ruby 1.7%