Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

SaltyRTC Relayed Data Task for JavaScript

CircleCI npm Version npm Downloads License Join our chat on Gitter

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

Installing

Via npm

You can install this library (and its peer dependencies) via npm:

npm install --save @saltyrtc/task-relayed-data @saltyrtc/client tweetnacl msgpack-lite

Usage

Create a new task instance:

const task = new RelayedDataTask();

(If you want to enable debug console messages, you can pass true to the constructor:)

const task = new RelayedDataTask(true);

Once the connection is established (when the SaltyRTC instance raises the state-change:task event), you can send messages using the sendMessage method:

task.sendMessage("hello");
task.sendMessage({"type": "custom", "value": "You can also send objects"});

When a new message arrives from the peer, an event is emitted. You can register and deregister event handlers with the on, once and off methods:

task.on('data', (ev) => {
    console.log('New data message arrived:', ev.data);
});

The following events are available:

  • data: A new message from the peer was received.

Testing

To run tests:

npm run build_tests

Then open tests/testsuite.html in your browser.

To run linting checks:

npm run lint

You can also install a pre-push hook to do the linting:

echo -e '#!/bin/sh\nnpm run lint' > .git/hooks/pre-push
chmod +x .git/hooks/pre-push

Security

Responsible Disclosure / Reporting Security Issues

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

License

MIT, see LICENSE.md.

About

JavaScript implementation of the Relayed Data task.

Resources

License

Packages

No packages published