Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@messagebird/webrtc

Package Overview
Dependencies
Maintainers
24
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@messagebird/webrtc

## Initializing an RTC Client

  • 0.0.2
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-37.5%
Maintainers
24
Weekly downloads
 
Created
Source

JavaScript WebRTC SDK

Initializing an RTC Client

To enable your application to make and receive calls over WebRTC, you have to instantiate a new WebRTCClient (TODO: good name? Device). To instantiate a client and authenticate with your MessageBird account you need to generate a JWT and pass it to the client (docs)

const client = new WebRTCClient({
  displayName: 'test',
  username: 'test',
  jwt: 'test',
});

// Open a connection to the MessageBird WebRTC API
client
  .connect()
  .then(() => {
    // Ready to start and receive WebRTC connections.
  })
  .catch(error => {
    // Error making a connection. The error object contains details of the failure.
  });

Starting a new RTC session

Make sure you've instantiated the WebRTCClient and opened the connection by calling the .connect() method. After succesfully instantiating a new client you can start new RTC sessions by calling the starRTCSession method.

client
  .startRTCSession({
    to: '+31612345678', // TODO: This will become `flowId` probably?
    onEnded() {
      console.log('session was ended');
    },
  })
  .then(connection => {
    // resolves with a connection object (docs)
  })
  .catch(error => {
    // Failed to start a session, error object contains details.
  });

API Reference

WebRTCClient

constructor()
startRTCConnection()
connect()

Connect to the

events
on('connected')

When the client connects. Can be called multiple times in case the client disconnects and automatically reconnects.

on('disconnected')

When the client disconnects for a certain reason. (docs on data object with reason)

RTCSession

The RTCSession object describes an ongoing RTC session. You will never instantiate an RTCSession yourself, the SDK will take care of that for you.

disconnect()

Terminates the session

on(name, handler)

Bind a new event listener. See Events (link) below

removeEventListener(name, handler)

Removes an event listener

Events
on('confirmed')
on('failed')
on('ended')

FAQs

Package last updated on 15 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc