JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 59
  • Score
    100M100P100Q76681F
  • License MIT

A SaltyRTC WebRTC task implementation.

Package Exports

  • @saltyrtc/task-webrtc

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@saltyrtc/task-webrtc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

SaltyRTC WebRTC Task for JavaScript

CircleCI Supported ES Standard npm Version npm Downloads License Chat on Gitter

This is a SaltyRTC WebRTC task implementation for JavaScript (ES5 / ES2015), written in TypeScript 2.

Warning: This is beta software. Use at your own risk. Testing and review is welcome!

Installing

Via npm

You can install this library via npm:

npm install --save @saltyrtc/task-webrtc @saltyrtc/client

Usage

When creating the task instance, you can specify whether or not a handover to a secure data channel is desired.

let task = new WebRTCTask(true);

You can also specify the max DataChannel chunk size:

let task = new WebRTCTask(true, 65536);

If you don't specify any values, handover defaults to true and the chunk size defaults to 16384.

The handover can be initiated using the handover method:

let started = task.handover(peerConnection);

Note: You should call this method before creating offer/answer!

To send offers, answers and candidates, use the following task methods:

  • .sendOffer(offer: RTCSessionDescriptionInit): void
  • .sendAnswer(answer: RTCSessionDescriptionInit): void
  • .sendCandidate(candidate: RTCIceCandidateInit): void
  • .sendCandidates(candidates: RTCIceCandidateInit[]): void

You can register and deregister event handlers with the on, once and off methods:

task.on('candidates', (e) => {
    for (let candidateInit of e.data) {
        pc.addIceCandidate(candidateInit);
    }
});

The following events are available:

  • offer(saltyrtc.tasks.webrtc.Offer): An offer message was received.
  • answer(saltyrtc.tasks.webrtc.Answer): An answer message was received.
  • candidates(saltyrtc.tasks.webrtc.Candidates): A candidates message was received.
  • disconnected(number): A previously authenticated peer disconnected from the signaling server.

To know when the handover is finished, please subscribe to the handover event on the client directly.

Testing

To compile the test sources, run:

$ npm run rollup_tests

Then simply open tests/testsuite.html in your browser!

Alternatively, run the tests automatically in Firefox and Chrome:

$ npm test

Security

Responsible Disclosure / Reporting Security Issues

Please report security issues directly to one or both of the following contacts:

Coding Guidelines

  • Write clean ES2015
  • Favor const over let

License

MIT, see LICENSE.md.