How to use the peerjs.Peer function in peerjs

To help you get started, we’ve selected a few peerjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kumavis / node-warrior / src / js / util / rtc_utils.js View on Github external
function RtcConnection(id) {
  var rtc = new Peer(id,{key: __ApiKey})
  rtc.on('open', function(id) { console.log('>> opened, got id:',id) })
  rtc.on('error', function(err) { console.log('>> had error:'); throw err })
  rtc.on('close', function() { console.log('>> closed') })
  rtc.on('connection', function(dataConnection) {
    console.log('>> got connection')
    // connection open
    dataConnection.on('open',function() {
      dataConnectionHasOpened(rtc,dataConnection)
    })
  })
  return rtc
}

peerjs

PeerJS client

MIT
Latest version published 5 months ago

Package Health Score

86 / 100
Full package analysis