Skip to content

Instantly share code, notes, and snippets.

@3rd-Eden
Created July 27, 2011 19:07
Show Gist options
  • Save 3rd-Eden/1110112 to your computer and use it in GitHub Desktop.
Save 3rd-Eden/1110112 to your computer and use it in GitHub Desktop.
<script src="/socket.io/socket.io.js"></script>
<script>
var chat = io.connect('/chat')
, news = io.connect('/news');
chat.on('connect', function () {
console.log('connect called on chat');
chat.emit('hi!');
});
news.on('news', function () {
console.log('connect called on chat');
news.emit('woot');
});
</script>
info - socket.io started
debug - served static /socket.io.js
debug - client authorized
info - handshake authorized 966600246121372668
debug - setting request GET /socket.io/1/jsonp-polling/966600246121372668/?t=1311793679073&i=0
debug - setting poll timeout
debug - client authorized for
debug - clearing poll timeout
debug - jsonppolling writing io.j[0]("1::");
debug - set close timeout for client 966600246121372668
debug - jsonppolling received data packet &#65533;8&#65533;1::/chat&#65533;8&#65533;1::/news
debug - setting request GET /socket.io/1/jsonp-polling/966600246121372668/?t=1311793679079&i=0
debug - setting poll timeout
debug - discarding transport
debug - cleared close timeout for client 966600246121372668
info - socket.io started
debug - served static /socket.io.js
debug - client authorized
info - handshake authorized 9384262431059425793
debug - setting request GET /socket.io/1/jsonp-polling/9384262431059425793/?t=1311793716987&i=0
debug - setting poll timeout
debug - client authorized for
debug - clearing poll timeout
debug - jsonppolling writing io.j[0]("1::");
debug - set close timeout for client 9384262431059425793
debug - setting request GET /socket.io/1/jsonp-polling/9384262431059425793/?t=1311793716993&i=0
debug - setting poll timeout
debug - discarding transport
debug - cleared close timeout for client 9384262431059425793
debug - jsonppolling received data packet ?8?1::/chat?8?1::/news
debug - client authorized for /chat
debug - clearing poll timeout
debug - jsonppolling writing io.j[0]("1::/chat");
debug - set close timeout for client 9384262431059425793
connection
debug - jsonppolling received data packet ?8?1::/chat?8?1::/news
debug - client authorized for /news
connection
debug - setting request GET /socket.io/1/jsonp-polling/9384262431059425793/?t=1311793717004&i=0
debug - setting poll timeout
debug - clearing poll timeout
debug - jsonppolling writing io.j[0]("?73?5::/chat:{\"name\":\"a message\",\"args\":[{\"that\":\"only\",\"/chat\":\"will get\"}]}?75?5::/chat:{\"name\":\"a message\",\"args\":[{\"everyone\":\"in\",\"/chat\":\"will get\"}]}?8?1::/news?49?5::/news:{\"name\":\"item\",\"args\":[{\"news\":\"item\"}]}");
debug - set close timeout for client 9384262431059425793
debug - discarding transport
debug - cleared close timeout for client 9384262431059425793
debug - jsonppolling received data packet 5::/chat:{"name":"hi!"}
debug - setting request GET /socket.io/1/jsonp-polling/9384262431059425793/?t=1311793717008&i=0
debug - setting poll timeout
debug - discarding transport
debug - cleared close timeout for client 9384262431059425793
var static = require('node-static');
var file = new(static.Server)('.');
var app = require('http').createServer(function (request, response) { request.addListener('end', function () { file.serve(request, response); }); });
var io = require('../../socket.io').listen(app);
io.configure(function () {
io.set('transports', ['jsonp-polling']);
});
var chat = io
.of('/chat')
.on('connection', function (socket) {
console.log('connection');
//console.log(socket);
socket.emit('a message', {
that: 'only'
, '/chat': 'will get'
});
chat.emit('a message', {
everyone: 'in'
, '/chat': 'will get'
});
});
var news = io
.of('/news')
.on('connection', function (socket) {
console.log('connection');
socket.emit('item', { news: 'item' });
});
app.listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment