peers / peerjs

Simple peer-to-peer with WebRTC.
https://peerjs.com
MIT License
12.41k stars 1.43k forks source link

working example? #696

Open gittyup2018 opened 4 years ago

gittyup2018 commented 4 years ago

Is there a working client example? There seems not to be any working example on the peerjs site, this respository and even the https://github.com/peers/peerjs-examples is completely empty. I found https://cdn.peerjs.com/demo/videochat from a google search but that gives a 404 error also.

Do I have to accept the offer before actually connecting? I thought I only have to pass the connection ID.

I was trying to make my own simple chat/text based demo on the documentation but it seems to not be able to send or receive data. I receive the offer but don't know what else to do? Someone mentioned

peer.on('connection', function(conn) { conn.open = true });

but this .open is not documented, is that for video/audio calls only?

Do I still have to call the call event for simple strings or is that video/audio calls only? because I never receive the on('data' conn event from

conn.on('open', function() { console.log("CONNECTED");

// Receive messages conn.on('data', function(data) { console.log('Received> ', data); });

// Send messages conn.send('Hello!'); });

The console displays CONNECTED, but not the hello message.

Do I only have to connect to a remote peer once to initialize the connection? Or does the remote peer have to call connect back to the initializer peer id? both seem to not work.

Andy-Kerr commented 4 years ago

Same issue as #693.