An open API service indexing awesome lists of open source software.

https://github.com/lostsource/simplertcdata

Browser-to-Browser Messaging Simplified
https://github.com/lostsource/simplertcdata

Last synced: about 1 month ago
JSON representation

Browser-to-Browser Messaging Simplified

Awesome Lists containing this project

README

        

# [![SimpleRTCData](http://i.imgur.com/BQpkqkE.png)](#)

SimpleRTCData is a tiny JavaScript library which can be used to establish an RTCDataChannel between two peers. It does not handle relaying of messages during connection setup so a separate signalling mechanism is required.

- [How it works](#how-it-works)
- [Basic Usage](#basic-usage)
- [Constructor](#constructor)
- [Methods](#methods)
- [close](#close)
- [getAnswer](#getanswer)
- [getConnection](#getconnection)
- [getDataChannel](#getdatachannel)
- [getOffer](#getoffer)
- [request](#request)
- [send](#send)
- [setAnswer](#setanswer)
- [Events](#events)
- [on('connect')](#onconnect)
- [on('data')](#ondata)
- [on('disconnect')](#ondisconnect)
- [on('request')](#onrequest)
- [onChannelEvent](#onchannelevent)
- [onConnectionEvent](#onconnectionevent)

## How it works

1. Peer A calls `getOffer` and sends the offer to Peer B
2. Peer B calls `getAnswer` and sends the answer to Peer A
3. Peer A calls `setAnswer` using the answer received from Peer B

*You may want to go through these steps using this [online example](https://lostsource.github.io/SimpleRTCData/)*

[![SimpleRTCData Signalling Example](http://i.imgur.com/jljAcGQ.png)](https://lostsource.github.io/SimpleRTCData/)

## Basic Usage

Start by including the library in your markup,