How can I make a browser to browser (peer to peer) connection in HTML?

HTMLJavascriptProgramming Scripts

For the browser to browser connection, follow the below-given steps −

All the following library −

<script src = "http://cdn.peerjs.com/0.3/peer.js"></script>

Create a peer −

For creating a peer, you need to get a free API key.

var peer = new Peer('pick-an-id', {key: 'myapikey'});

Connect −

var conn = peer.connect('another-peers-id');
conn.on('open', function(){
   conn.send('Welcome!');
});
raja
Published on 21-Mar-2018 06:28:28
Advertisements