WebSockets? I just recently ran across websockets and have heard some good things about it but have found html5 is not really readily available at this time so would it be worth it to change over to writing a browser based MMO into websockets and getting the gamers to upgrade/download what they need or use comet and if someones browser supports websockets; run it that way? Any thoughts?
WebSocket provides a client-server computer communication protocol, whereas WebRTC offers a peer-to-peer protocol and communication capabilities for browsers and mobile apps. While WebSocket works only over TCP, WebRTC is primarily used over UDP (although it can work over TCP as well).
In programming, a socket is an endpoint of a communication between two programs running on a network. Sockets are used to create a connection between a client program and a server program. Sockets API is available in the Node. js net module.
Answer: It's not too new and you can use now on almost every browser.
WebKit has had WebSockets support for quite a while (basically anybody using Safari or Chrome has it). Starting with iOS 4.2 WebSockets have been turned on (Apple had left it de-activated in previous versions). Opera 11.0 will have it (10.7 is now 11.0). Firefox 4.0 has it included but disabled by default (enabled in about:config). Firefox 5.0 or 6.0 will likely have it on by default.
For other browsers you can use web-socket-js which is a Flash based fallback. It works well and it's easy to do automatic fallback. It is slower than native WebSockets but still has far lower latency then AJAX/COMET.
If Javascript is a valid option for the backend then you might consider using Node and the Socket.IO library for Node. Socket.IO is mainly a server-side library that supports WebSockets (it incorporates the web-socket-js falback) and various AJAX/COMET/long-poll methods. The client side of Socket.IO allows you to use the same API as on the server side (it's very similar to the normal WebSockets API) and it does detection and selects the optimal transport. The AJAX/COMET/long-poll transports are only used if the browser doesn't have native WebSockets and you choose not to use the fallback.
Included with noVNC (HTML5 VNC client) is websockify which is a WebSockets to TCP socket proxy. There are three implementations: C, python and Node. It might be a useful reference for you. noVNC transfers large amounts of data over WebSockets and it is very sensitive to latency. The Flash fallback is definitely less efficient, but it is still has very usable performance. (Disclaimer: I made noVNC)
In summary: the only place WebSockets is not supported right now is browsers without native WebSockets and without Flash (i.e. current iOS and older Android phones).
A couple of misc notes:
I find http://caniuse.com to be best resource for HTML5 (and related) browser support information.
HTML5 Cross-browser Polyfills is a very useful (and long) list of shims, fallbacks, and polyfills that add HTML5 features to browsers that don't support them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With