background preloader

The cross-browser WebSocket for realtime apps.

The cross-browser WebSocket for realtime apps.
What is Socket.IO? Socket.IO aims to make realtime apps possible in every browser and mobile device, blurring the differences between the different transport mechanisms. It's care-free realtime 100% in JavaScript. Server Client How to use Installing npm install socket.io Using with Node HTTP server For this example, simply run `npm install socket.io` Server (app.js) Client (index.html) Using with the Express 3 web framework Express 3 requires that you instantiate a `http.Server` to attach socket.io to first: Using with the Express web framework You can serve normal pages and AJAX requests with Express, and attach your socket.io server For this example, simply run `npm install socket.io express` Sending and receiving events. Socket.IO allows you to emit and receive custom events. Storing data associated to a client Sometimes it's necessary to store data associated with a client that's necessary for the duration of the session. Restricting yourself to a namespace. Sending volatile messages. Desktop Mobile

Session-based Authorization with Socket.IO HEADS UP! This article was written for an older version of node. More up-to-date information may be available elsewhere. Finding a decent article about session based authorization in socket.io is more difficult than one expected. This article will show how you can take advantage of Express session middleware and socket.io authorization middleware to create a very simple authorization mechanism when establishing new socket.io connections. Prolog I decided to write this article after getting a bit frustrated from searching the Internet for a decent example on how to use session based authorization with socket.io. Disclaimer: the original concept was published in Daniel Baulig's blog. Reading Suggestions Before reading this article, I strongly suggest you get familiar with Express and Socket.IO. I also suggest reading the Authorization wiki page referenced in the prolog. Global Authorization vs Namespace Authorization A Few Words about Timing Session-based Authorization Time to Code! index.html

LearnBoost/socket.io Configuring Socket.IO ยท LearnBoost/socket.io Wiki

Related: