Created
July 25, 2011 19:33
-
-
Save ericz/1104972 to your computer and use it in GitHub Desktop.
jsonp client -> server message issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="/socket.io/socket.io.js"></script> | |
<script> | |
var socket = io.connect(); | |
socket.on('connect', function(){ | |
socket.emit('print', 'a'); | |
socket.emit('print', 'b'); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); | |
}); | |
io.sockets.on('connection', function (socket) { | |
socket.on('print', function(msg) { | |
console.log(msg); | |
}); | |
}); | |
app.listen(80); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment