@nystik/firewire-rtc
v0.1.4
Published
WebRTC signaler using firestore.
Readme
Firebase WebRTC Signaling
NOTE: This is a hobby project with no expectation of support or maintenance.
Description
A WebRTC signaler that uses firestore to negotiate the peer connection. Follows the WebRTC perfect negotiation pattern.
Installation
npm install --save-dev @nystik/firewire-rtcUsage
Remember to initialize your firebase app before using the signaler.
import { initializeApp } from 'firebase/app'
const firebaseConfig = {
apiKey: '<API KEY>',
...
}
initializeApp(firebaseConfig)import { getSignaler } from 'firewire-rtc'
// Create a peer connection
const peer = new RTCPeerConnection()
// Create signaler for the peer connection and set wether this peer is polite or not (see: https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Perfect_negotiation)
const polite = false
const signaler = getSignaler(peer, polite)
// Create a negotiation
const negotiationId = signaler()
...
// Or connect to an existing negotiation
signaler('<negotiation-id>')At this point all offers, answers, and ice candidates are handles by the signaler and we can add streams and data channels to the peer connection as we wish.
...
stream.getTracks().forEach((track) => peer.addTrack(track, stream))
...Known Issues
- if you get
Error: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp()you need to tell your bundler to remove duplicate imports. For rollup adddedupe: ['firebase']to the node-resolve plugin options.
License
This project is licensed under the MIT license, see LICENSE for details.
