Is WebRTC Right? (real-time multiplayer game)

Imagine I want to create a real-time multiplayer game, with HTML5 (client) and node.js (server).

I need to transfer data from the server to clients very quickly and vice versa.

In my own application, I would use UDP for most data (player position, ...), because it is faster than TCP , and it is uncritical when it is lost.

In HTML5 I can (only) use WebSockets . WebSockets is on top of TCP and therefore not fast enough for good performance.

I heard about WebRTC , but I don't know if this could be the solution to this problem.

Does anyone have any experience?

(I know that WebRTC is still not supported for most browsers, but it doesn't matter to me.)

+7
source share
2 answers

In terms of WebRTC, it sounds the way you need it, it's a DataChannel: see draft protocol and HTML5 Rocks article (disclaimer: I wrote it!)

DataChannel is a work in progress that has not yet been implemented by any browser.

As with other WebRTC components, MediaStream (getUserMedia) is supported by Chrome, Firefox Nightlies, and Opera; RTCPeerConnection is stable in Chrome, behind the flag (flagship in future versions) and promised Firefox 18 in the first quarter of 2013.

EDIT: RTCDataChannel is now implemented in Firefox and Chrome.

Chrome demo 'single page': simpl.info/dc , demo version of Firefox .

+2
source

RTCDataChannel provides session / reliable, as well as inconclusive / unreliable transport, similar to TCP and UDP in its own client, respectively. More details here . Since 2013, it has been a viable technology, albeit only in later versions of Chrome and Firefox.

According to html5rocks.com, you can now also use binary types for transmission. Thus, you should have all the features that you have with an effective, native UDP client. However, Iโ€™m not sure yet that the binary migration made its way from the webrtc repository where it was fixed , right up to Chrome, or that it is still only available in Chrome Canary at this point.

+1
source

All Articles