Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this work in a closed network (f.e. on a wifi network with no internet)? #29

Open
trusktr opened this issue Jun 12, 2017 · 6 comments

Comments

@trusktr
Copy link

trusktr commented Jun 12, 2017

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?

@dicoy-zz
Copy link

Yes, just download the project on each machine and open the html file in a browser

@trusktr
Copy link
Author

trusktr commented Jun 12, 2017

What are the limitations? Do they need to be on the same network? Or does this also work over internet? Any other limitations?

@trusktr
Copy link
Author

trusktr commented Jun 12, 2017

How does speed compare to Web sockets for streaming data? Have you compared by chance?

@cjb
Copy link
Owner

cjb commented Jun 13, 2017

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.

@trusktr
Copy link
Author

trusktr commented Jun 13, 2017

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.

@shenzhuxi
Copy link

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants