SimpleWebRTC: usage example of sendDirectlyToAll

2018-03-10 11:12:07 WebRTC, Javascript

How to send text or data to all peers in SimpleWebRTC by using sendDirectlyToAll method.

Here is my usage example showing how i managed to get it working:

* send directly to all other peers
    'meta',         // sLabel
    'info',         // sType - will become oData.sType
    {"foo": "bar"}  // oData - will become oData.payload

* Handle incoming dataChannel messages sent by "sendDirectlyToAll"
* @param {object} oPeer The Remote sending Peer Object
* @param {string} sLabel A Label, e.g.: 'meta'
* @param {object} oData Object containing the relevant Data
oSimpleWebRTC.on('channelMessage', function (oPeer, sLabel, oData) {

    // e.g. we want label "hark" to be ignored, as it fires continiously.
    if ('hark' === sLabel) {
        return true;

    if ('meta' === sLabel) {

        if ('info' === oData.type)
            // do your stuff



E-Mail Adresse wird nicht veröffentlicht.
E-mail address will not be published.