本地网络上的WebRTC? [英] WebRTC on local network?

查看:44
本文介绍了本地网络上的WebRTC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关 WebRTC 的文章,它看起来很有前途.我想做一个简单的局域网游戏,可以自动连接同一网络上的人.虽然我可以找到人们询问类似的问题,并且答案告诉他们这是可能的,但我找不到任何关于如何完成的明确教程.

I've been reading about WebRTC and it looks very promising. I wanted to make a simple lan game that automatically connects people on the same network. Though I could find people asking about something similar, and answers telling them it was possible, I couldn't find any clear tutorials on how it can be done.

不过,我对 WebRTC 和一般的网络编程非常陌生.所以也许我只是不知道要搜索什么.

I am however very new to WebRTC and web programming in general. So maybe I just don't know what to search for.

那么,如何在本地网络上使用 WebRTC 自动连接人们,而无需任何人运行单独的服务器或连接到互联网?他们应该能够在他们的计算机上打开一个 html 文件并连接到同一网络上的其他人,即使没有互联网.

So, how can I automatically connect people using WebRTC on a local network without anyone having to run a separate server or connect to the internet? They should be able to open a html file on their computer and connect to everyone else doing that on the same network, even when there's no internet.

谢谢!

推荐答案

至少一台机器需要成为服务器,因为它需要打开一个端口来监听.这是一个与所有联系相关的生活事实;当一台机器打开连接时,另一端需要有另一台机器响应.没有这个,就无法建立任何联系.

At least one machine needs to be a server, in the sense that it needs to have a port open that it listens on. This is a fact of life with all connections; when one machine opens a connection, there needs to be another machine on the other end that responds. Without this, no connections can ever be made.

如果您愿意让一台或所有机器监听一个端口,那么您可以在 LAN 上设置 WebRTC.在这种情况下,您将不需要 STUN 或 TURN,因为没有 NAT 遍历.

If you are willing to have one or all machines listening on a port, then you can setup WebRTC on a LAN. In this case, you will not need STUN or TURN because there is no NAT traversal.

WebRTC 在 LAN 上不需要 STUN 或 TURN.WebRTC 端点可以使用它们在 LAN 上的已知地址生成本地 ICE 候选对象.这些通过信令交换,或者直接在 SDP 中,或者作为涓流 ICE 中的 ICE 候选.无需联系 LAN 外部的 STUN 服务器即可建立对等连接.

WebRTC does not need STUN or TURN on a LAN. WebRTC endpoints can generate local ICE candidates using their known addresses on the LAN. These get exchanged through signaling, either in directly in the SDP, or as ICE candidates in trickle ICE. The peer connection can be setup without ever needing to contact a STUN server external to the LAN.

这篇关于本地网络上的WebRTC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆