5 ms·
Multiplayer functionality doesn't seem to be working for me. Is this just me, or an artifact of the compilation?
by goddtriffin 8y ago
Multiplayer functionality doesn't seem to be working for me. Is this just me, or an artifact of the compilation?
- db48x 8y agoThe browser doesn't provide the usual POSIX api for opening TCP connections. With some work you can write a shim library that implements it in terms of websockets, but it still can't connect to arbitrary hosts. Instead you have to run a proxy server for it to connect to.
- reubenmorais 8y agoCould you use WebRTC instead, for true P2P?
- db48x 8y agoYou still need a proxy server, unless the OpenTTD game browser supports WebRTC connections.
- jeremija 8y agoYeah, you'd need a proxy server (websockets) to establish WebRTC connections. Even after a WebRTC connection is established, you'd need a STUN or a TURN (coturn supports both) server to get around NATs. Pls somebody correct me if I'm wrong!
- tim-- 8y agoYou should only need a STUN or TURN server if you are attempting to connect to a machine that is behind a NAT. OpenTTD servers are usually on public IPs (similar to HTTP servers), so a STUN or TURN server should not be required. The biggest issue is that WebRTC connections do not allow you to send raw data over TCP or UDP[1]. That being said, it shouldn't be too difficult to just create a WebSocket server that translates between the native network protocol and HTTP WebSockets[2]. [1] https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel [2] https://wiki.openttd.org/Network_Protocol
- db48x 8y agoYou're entirely correct. Here's a demo if you're interested: http://vrcade.io/win311 http://vrcade.io/win311
- lxtx 8y agoYou can. I've used WebRTC for multiplayer support in Quake 3 compiled to WebAssembly.