Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Socket.IO 0.6 released. Parent comment
1) One line to install
npm install socket.io
2) Three lines two use on the server
var io = require('socket.io');
var socket = io.listen(yourHttpServerInstance);
socket.on('connection', function(conn){ conn.on('message', function(msg){ console.log('message from client', msg); }); }
3) Three lines to use on the client
<script src="/socket.io/socket.js"></script> <!-- assuming node serves the HTML too -->
var socket = new io.Socket().connect();
socket.send('my message!');
There are no comments on this comment yet.
1) One line to install
npm install socket.io
2) Three lines two use on the server
var io = require('socket.io');
var socket = io.listen(yourHttpServerInstance);
socket.on('connection', function(conn){ conn.on('message', function(msg){ console.log('message from client', msg); }); }
3) Three lines to use on the client
<script src="/socket.io/socket.js"></script> <!-- assuming node serves the HTML too -->
var socket = new io.Socket().connect();
socket.send('my message!');