Last active
August 29, 2015 14:02
-
-
Save capaj/d8c577599987bdd83d4b to your computer and use it in GitHub Desktop.
socket.io namespace problem 1.0.1-1.0.3
This file contains hidden or 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
<html> | |
<body> | |
<h1>no namespace</h1> | |
</body> | |
<script src="/socket.io/socket.io.js"></script> | |
<script> | |
var socket = io('/'); | |
socket.emit('my other event', { my: 'data1212' }); | |
</script> | |
</html> |
This file contains hidden or 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
<html> | |
<body> | |
<h1>namespace /myNsp</h1> | |
</body> | |
<script src="/socket.io/socket.io.js"></script> | |
<script> | |
var socket = io('/myNsp'); | |
socket.emit('my other event', { my: 'sent immediately' }); | |
setTimeout(function (obj) { | |
socket.emit('my other event', { my: 'sent with timeout' }); | |
}, 50); //values higher than 20ms work for me | |
</script> | |
</html> |
This file contains hidden or 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
{ | |
"name": "socket.io-1-0-test", | |
"private": false, | |
"dependencies": { | |
"express": "4.4.0", | |
"socket.io": "1.0.3" | |
} | |
} |
This file contains hidden or 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 express = require('express'); | |
var app = express(); | |
var server = app.listen(7070); | |
var io = require('socket.io')(server); | |
io.on('connection', function (socket) { | |
console.log('conn event'); | |
socket.on('my other event', function (data) { | |
console.log(data); //is called as expected | |
}); | |
}); | |
app.get('/', function (req, res) { | |
res.sendfile(__dirname + '/index_no_nsp.html'); | |
}); |
This file contains hidden or 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 express = require('express'); | |
var app = express(); | |
var server = app.listen(7070); | |
var io = require('socket.io')(server); | |
io.of('/myNsp').on('connection', function (socket) { | |
console.log('conn event'); | |
socket.on('my other event', function (data) { | |
console.log(data); // does not get ever called, THE BUG | |
}); | |
}); | |
app.get('/', function (req, res) { | |
res.sendfile(__dirname + '/index_nsp.html'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment