You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lennart Grahl 7031d82e56 Add test for Uint8Array and Int32Array views with offset 11 months ago
.circleci Switch to CircleCI 2 years ago
dist Release v0.13.0 11 months ago
rollup Upgrade rollup and other dependencies 1 year ago
src Send optimisations & don't ignore Uint8Array offsets 11 months ago
tests Add test for Uint8Array and Int32Array views with offset 11 months ago
.editorconfig Update .editorconfig 2 years ago
.gitignore Setup testing and distribution 2 years ago
CHANGELOG.md Release v0.13.0 11 months ago
LICENSE.md Upgrade copyright year 1 year ago
README.md Improve README 1 year ago
RELEASING.md Release v0.12.1 1 year ago
karma.conf.js Increase karma browser timeout 2 years ago
package-lock.json Release v0.13.0 11 months ago
package.json Fix apply the log level on SecureDataChannel 11 months ago
saltyrtc-task-webrtc.d.ts Add log level (defaults to 'none') 11 months ago
tsconfig.json Switch to dependencies in @saltyrtc organization 2 years ago

README.md

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.