serverless-webrtc
serverless-webrtc copied to clipboard
Does this work in a closed network (f.e. on a wifi network with no internet)?
Does this work in a closed network (f.e. on a wifi network with no internet)?
I'd like to connect two devices by running code in each device's browser. They are on the same network via WiFi, without internet.
Is this what can be done?
Yes, just download the project on each machine and open the html file in a browser
What are the limitations? Do they need to be on the same network? Or does this also work over internet? Any other limitations?
How does speed compare to Web sockets for streaming data? Have you compared by chance?
Why not just try it?
WebRTC datachannels are faster than websockets in the sense that WebRTC supports UDP and websockets only support TCP. So if you're building something that wants UDP-like behavior, like streaming movies or multiplayer games, you would probably prefer WebRTC.
I just gave it a shot. I don't see where I get the "answer" from. On the first tab, I type "hello" in the box after hitting "create" server. Then it shows a box to input the "answer". Then in the second tab I hit "join", and type "hello" in the box. I don't see where to get the answer.
@trusktr You need to wait a while after hitting "create" server to see the "offer text" show up in the textarea (it's not for inputting any text).
It took me a while to aware the time needed for ICE by comparing the code for browser and node.js.
pc1.onicecandidate = function (e) {
console.log('ICE candidate (pc1)', e)
if (e.candidate == null) {
$('#localOffer').html(JSON.stringify(pc1.localDescription))
}
}
pc.onicecandidate = function(candidate) {
// Firing this callback with a null candidate indicates that
// trickle ICE gathering has finished, and all the candidates
// are now present in pc.localDescription. Waiting until now
// to create the answer saves us from having to send offer +
// answer + iceCandidates separately.
if (candidate.candidate == null) {
doShowAnswer();
}
}
In your case, in a closed network, you can delete iceServers from var cfg = {'iceServers': [{'url': 'stun:23.21.150.121'}]} to make offer text generation instant.
@cjb I think it will be better to update the text "Here's your "offer" -- it tells someone else how to connect to you. Send the whole thing to them, for example in an instant message or e-mail." into something like "Wait your "offer" JSON text show up (It may take a while). Then copy/paste and send the text to the peer you want to connect. "
Also make the textarea read only... Also add a waiting animation...
BTW, this project is a good example to understand WebRTC. Thanks!