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

We've been using WebRTC Datachannels for multiplayer gaming in the browser in our game editor Construct 2 (www.scirra.com) for a couple of years now. Generally they work great! However the main problem we have is switching tab suspends the game, which if you're acting as the host, freezes the game for everybody. This is really inconvenient. There ought to be some way to exempt tabs with WebRTC connections from being suspended. I filed a bug for it here: https://bugs.chromium.org/p/chromium/issues/detail?id=676036



Is it possible to run WebRTC in a webworker?


Wait can you do a pop out window? That way it's always open and can't have multiple tabs. The main tab can control the pop out to kill the data channel ...


Minimising still suspends. And IMO pop-ups are slightly user hostile compared to just staying in the tab.


Have you tried popping up a message in other browsers saying 'userBob switched browser tabs, disabling his host. Please contact userbob to switch back and always remeber if you are the host, dont switch tabs.' Then it would only happen when people were trying to be hostile or negligent.

Also have you tried with a webworker or something similar.


The answer is a server hosting the games, but that costs money.


Websockets are much simpler if you just want to do server<>client. A lot of webrtc is to handles the problems that come with p2p.


AFAIK, websockets can't UDP (which is useful for many games).


Not only can they not do UDP, they are framed as HTTP connections so until HTTP supports an alternative transport, WS is stuck.


Exactly, the appeal of P2P is you don't need to run servers. And it seems like a reasonable feature to allow browsers to reliably host multiplayer games.


> it seems like a reasonable feature to allow browsers to reliably host multiplayer games.

We're at a point now where you're certainly not wrong, it just feels really wrong.


Are you using any libraries to simplify the initial handshake connection or Socket.io?


No, we run our own signaling server and wrote the connection establishment parts ourselves. The client ends aren't that complicated in that regard.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: