HTML and CSS Reference
In-Depth Information
Here is an example using the Graceful WebSocket library. We chose Graceful We-
bSocket because it is simple, lightweight, makes no use of Flash, and exposes func-
tionality similar to the WebSocket API.
First of all, download the library, along with jQuery, and include them in your project:
<script src=" jquery-1.9.1.min.js"></script>
Structure your document as you would normally do and simply replace any reference
to the WebSocket native class with the gracefulWebSocket once!
Replace this:
var socket = new
with this:
var socket =
It is that simple! The rest of the WebSocket events and methods remain the same:
socket.onopen = function (event) {
// Handle the open event as previously.
socket.onclose = function (event) {
// Handle the close event as previously.
socket.onmessage = function (event) {
// Handle the message event as previously.
Search WWH ::

Custom Search