1.4.0 • Published 3 years ago

@signal-fire/client v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Signal-Fire Client

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.

Features

  • 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

Install using npm:

npm i @signal-fire/client

Documentation

Click here to view the documentation.

Example

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()
  })
}
1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago