peerjs
peerjs copied to clipboard
peersj not showing id in capacitor js app?
peer js throwing empty string id in capacitor?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input id="id" type="text" value="add">
<button id="connect">connect</button>
<script src="https://unpkg.com/[email protected]/dist/peerjs.min.js"></script>
<script>
var peer = new Peer();
peer.on('open', function(id) {
console.log('My peer ID is: ' + id);
});
peer.on('connection', function(conn) { console.log(conn) });
document.getElementById("connect").onclick=function(){
var id=document.getElementById("id").value
var conn = peer.connect(id);
conn.on('open', function() {
// Receive messages
conn.on('data', function(data) {
console.log('Received', data);
});
// Send messages
conn.send('Hello!dd');
});
}
</script>
</body>
</html>