Socket.io Duplicate clients on a namespace
Posted
by
Servernumber
on Stack Overflow
See other posts from Stack Overflow
or by Servernumber
Published on 2012-11-10T22:41:53Z
Indexed on
2012/11/10
23:00 UTC
Read the original article
Hit count: 142
Hi I'm trying to use dynamic namespace to create them on demand. It's working except that I get duplicate or more client for some reason
Server side :
io.of("/" + group ).on("connection", function(socket_group) {
socket_group.groupId = group;
socket_group.on("infos", function(){
console.log("on the group !");
})
socket_group.on('list', function () {
Urls.find({'group' : '...'}).sort({ '_id' : -1 }).limit(10).exec(function(err, data){
socket_group.emit('links', data);
});
})
[...]
})
Client Side :
socket.emit('list', { ... });
On the client side only one command is sent but the server is always responding with 2 or more responses. Every time I close/open my app the response is incremented.
Thanks if you find out.
© Stack Overflow or respective owner