icebreaker.io-client

1.0.0 • Public • Published

icebreaker.io-client

icebreaker.io enables peer-to-peer real-time communications, using WebRTC technology. It is built on top of socket.io, and it basically allows two peers to resolve how to connect over the internet and start an RTCPeerConnection. It consists in:

Installation

The package is currently in beta status, and should be installed with:

npm install icebreaker.io-client --save

How to use

icebreaker.io-client uses the same interface as socket.io-client, since it is built on top of it. As an example, below you can find how to initialize it using ES6 import:

import icebreaker from 'icebreaker.io-client';
const icebreakerClient = icebreaker('https://localhost:8443', {
  path: '/socket'
});

Once the client has been initialized, the webrtc connection can be started as showed below:

// These are events you can subscribe to:
icebreakerClient.events.connectionEnded.addOnce(yourConnectionEndedHandler);
icebreakerClient.events.getUserMediaError.addOnce(yourGetUserMediaErrorHandler);
icebreakerClient.events.localStreamReady.addOnce(yourLocalStreamReadyHandler);
icebreakerClient.events.remoteStreamReady.addOnce(yourRemoteStreamHandler);
 
// All the properties are optional
const props = {
  connId: 'my-test-connection',
  mediaConstraints: {
    audio: true,
    video: true
  },
  configuration: {
    iceServers: [
      { url: 'stun:stun.l.google.com:19302' }
    ]
  }
};
icebreakerClient.start(props).then(connId => {
  console.log('>>>>> The connection id is: ', connId);
});

The same code can be used for the two peers. If a peer is joining a connection that exists and that has another peer already in, the WebRTC connection between the two will be established. The remote stream can be accessed through the remoteStreamReady event.

Demo project

You can find a fully working demo project that uses both server and client icebreaker.io libraries here. It is a very basic video-chat application.

Tests

npm run test

This command runs the gulp task test, which runs the unit tests in the tests directory.

License

GPLv3

Readme

Keywords

Package Sidebar

Install

npm i icebreaker.io-client

Weekly Downloads

0

Version

1.0.0

License

GPL-3.0

Last publish

Collaborators

  • elbecita