1.1.0 • Published 4 years ago

@davey2/webrtc-signaling v1.1.0

Weekly downloads
-
License
-
Repository
github
Last release
4 years ago

WebRTC Signaling

Install

Install with npm

npm install @davey2/webrtc-signaling

or include in browser

<script src="https://unpkg.com/@davey2/webrtc-signaling"></script>

Usage

Constructor

const signaling = new WebRTCSignaling(/* optional id */);

Events

signaling.on("open", () => {
	console.log(signaling.id);
	// output: random uuid
});

signaling.on("error", error => {
	// possible errors:
	// - "id-busy" - the id in the constructor is already taken
	// - "unavailable-id" - the id does not exist
	console.error(error);
});

// receive incoming connections
signaling.on("connection", peer => {
	// peer type is RTCPeerConnection
});

Connect

const peer = signaling.connect("REMOTE-ID");
// peer type is RTCPeerConnection
// if the id is not exist, emit the error to error event listener
1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago