Giter Club home page Giter Club logo

peerdart's Introduction

Windmillcode PeerDart: Simple peer-to-peer with WebRTC

PeerDart provides a complete, configurable, and easy-to-use peer-to-peer API built on top of WebRTC, supporting both data channels and (planned) media streams.

PeerDart mirrors the design of peerjs. Find the documentation here.

  • supports socketio connections
  • sends chunks based on maxMessageSize from local and remote session descriptions

Status

  • Alpha: Under heavy development
  • Public Alpha: Ready for testing. But go easy on us, there will be bugs and missing functionality.
  • Public Beta: Stable. No breaking changes expected in this version but possible bugs. (media is public alpha)
  • Public: Production-ready

Setup

Create a Peer

<!-- for development -->
final Peer peer = Peer(options:PeerOptions(
      // debug: LogLevel.All,
));
<!-- for production -->
final Peer peer = Peer(options:PeerOptions(
      // debug: LogLevel.All,
      clientType: "socketio",
      host: "[YOUR SERVER DOMAIN]",
      port: 9000,
      secure: true));

Data connections

Connect

var peer;
if (peer?.id == null) {
    peer = Peer(options: APPENV.peerdart);
    wait peer!.init();
}

var conn = webrtc.connect(res.data.result["sender_peer_id"]);
conn.on("open",(data) async {
    conn.send("hi!");
})

Receive

if (peer?.id == null) {
    peer = Peer(options: APPENV.peerdart);
    wait peer!.init();
}
peer!.on("connection", (DataConnection? conn) {
    conn?.on("data", (dynamic data) async {
        <!-- work with your data -->
    })
})

Support

Works on android

Reference

Property Type Default Value Description
debug LogLevel? LogLevel.Disabled Log level for debugging.
host String? util.CLOUD_HOST Host address of the PeerServer.
port int? util.CLOUD_PORT Port on which the PeerServer is running.
path String? "/" Path to the PeerServer.
key String? Peer.DEFAULT_KEY API key for the PeerServer.
token String? randomToken() Token used for authentication.
config dynamic util.defaultConfig Configuration options for the RTC connection.
secure bool? true Whether the connection should be secure (https/wss).
pingInterval int? null Interval for sending ping messages to keep the connection alive.
referrerPolicy String? "strict-origin-when-cross-origin" Referrer policy for the HTTP requests.
clientType "websocket" | "socketio" "websocket" Type of client to use for the connection.
logFunction void Function(LogLevel logLevel, dynamic args)? null Custom log function.
serializers Map<String, DataConnection Function(String peerId, Peer provider, dynamic options)> {} Custom serializers for different data connection types.

Links

License

PeerDart is licensed under the MIT License.

peerdart's People

Contributors

judimax avatar

Stargazers

Kenneth Chu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.