Socket.IO middleware for Connect. (Or use Connect middleware from Socket.IO)
npm install socket.io-connect
var connect =// Setup your server with middlewareserver = connectio = ;server; // Listen for requestsvar socket = io; // Wrap your connect server with Socket.IO// socket.prefixWithMiddleware punts the client's request down// the Connect middleware if there is a Socket.IO 'connection' eventsocket;// If there's no 'connection' event, then the request gets passed to// the regular middleware
var connect =socketIOconnect = socketIOconnect;// Setup your server with middlewarevar server = connect;server; // Listen for requests
I have re-implemented the example chat application from the Socket.IO-node github repo, using Connect and Socket.IO-connect.
To run this example using method 1:
git clone http://github.com/bnoguchi/Socket.IO-connect.git --recursive cd Socket.IO-connect/example/ node server1.js
To run this example using method 2:
git clone http://github.com/bnoguchi/Socket.IO-connect.git --recursive cd Socket.IO-connect/example/ node server2.js
and then point your browser to http://127.0.0.1:8080.
Copyright (c) 2011 by Brian Noguchi
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.