Signal-Fire Client is a WebRTC signaling client for Signal-Fire Server.
A WebRTC signaling server communicates between peers to set up peer-to-peer audio/video and/or data channels. This allows your clients to communicate directly with each other.
- Works seamlessly with Signal-Fire Server
- Abstracts away the hassles of setting up peer connections
- Uses a simple, JSON-based protocol
- No forest of dependencies
Install using npm:
npm i @signal-fire/client
Click here to view the documentation.
Note: Is is assumed the server is running Signal Fire Server or a server which uses the same protocol.
See the documentation for more examples!
This example shows how to start a session.
import connect, { SessionAcceptedEvent } from '@signal-fire/client' async function run () { const client = await connect('ws://localhost:3003/socket') const session = await client.createSession('<target id>') session.addEventListener('accepted', (ev: SessionAcceptedEvent) => { console.log('Session accepted!') const connection = ev.detail const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true }) stream.getTracks().forEach(track => { connection.addTrack(track, stream) }) }) session.addEventListener('rejected', () => { console.log('Session rejected') }) session.addEventListener('timed-out', () => { console.log('Session timed out') }) }
This example shows how to accept a session.
import connect, { IncomingSessionEvent } from '@signal-fire/client' async function run () { const client = await connect('ws://localhost:3003/socket') client.addEventListener('session', (ev: IncomingSessionEvent) => { const session = ev.detail const connection = await session.accept() }) }