webrtc4me
v0.8.1
Published
# What is this?
Downloads
14
Readme
webrtc4me
What is this?
This is a webrtc wrapper library for browser and node.js.
Implemented very easy signaling way.
Support multi label datachannel and media stream.
How to use?
look src/tests/
example/
vanilla ice
const peerOffer = new WebRTC({ nodeId: "offer" });
const peerAnswer = new WebRTC({ nodeId: "answer" });
peerOffer.makeOffer();
const offer = await peerOffer.onSignal.asPromise();
peerAnswer.setSdp(offer);
const answer = await peerAnswer.onSignal.asPromise();
peerOffer.setSdp(answer);
await Promise.all([
peerOffer.onConnect.asPromise(),
peerAnswer.onConnect.asPromise()
]);
trickle ice
const peerOffer = new WebRTC({ nodeId: "offer", trickle: true });
const peerAnswer = new WebRTC({ nodeId: "answer", trickle: true });
peerOffer.makeOffer();
peerOffer.onSignal.subscribe(sdp => {
peerAnswer.setSdp(sdp);
});
peerAnswer.onSignal.subscribe(sdp => {
peerOffer.setSdp(sdp);
});
peerOffer.onConnect.once(() => {
});
peerAnswer.onConnect.once(() => {
});