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
- 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
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));
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 -->
})
})Works on android
PeerDart is licensed under the MIT License.
