Wednesday, 19 February 2020

Socket.io Duplicate clients on a namespace

Hi I'm trying to use dynamic namespace to create them on demand. It's working fine but every time I refresh than I get duplicate connection. Here is some code:socket.on('clientAccesRequest', function (res, cb) { mongo.clientAccesRequest(res, function (company) { cb(company) var SocketCompany = io.of('/' + company.companyID) SocketCompany.on('connection', function (socket) { console.log('customer connected') }) console: 2020-02-19 08:50:25.975: [server.js:35] anonymous user disconnect 2020-02-19 08:50:26.022: [server.js:29] anonymous user connected 2020-02-19 08:50:26.040: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.041: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.041: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.148: [server.js:35] anonymous user disconnect 2020-02-19 08:50:26.190: [server.js:29] anonymous user connected 2020-02-19 08:50:26.205: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.205: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.205: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.205: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.294: [server.js:35] anonymous user disconnect 2020-02-19 08:50:26.333: [server.js:29] anonymous user connected 2020-02-19 08:50:26.348: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.348: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.348: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.348: [socketCalls.js:36] anonymous customer connected 2020-02-19 08:50:26.348: [socketCalls.js:36] anonymous customer connected

Submitted February 19, 2020 at 08:50AM by milantran

No comments:

Post a Comment