Hacker News new | past | comments | ask | show | jobs | submit login

I'm curious how human multiplayer works with webassembly. I assume it uses websockets, but how does the code hook into it? How does the original code compile?



Qt and emscripten took care of the bulk of it. Emscripten turns socket calls into websocket somewhat "transparently". The error handling is slightly different, but it only took minor code changes to get that working. More effort was involved in making the Qt event loop play nicely in the browser. Freeciv is based on a server-client model, we host servers that the wasm clients connect to via websockets.


> we host servers that the wasm clients connect to via websockets.

would it be possible to make this completely p2p so that another browser hosts the server and connect to it via webRTC style?


It should be possible, but it would take more invasive netcode changes to be able to handle webRTC. Emscripten does not do similar translation of socket calls to webRTC.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: