Closed ansubur closed 5 years ago
Just trying get a particular socket with id.
var serverSocket = scServer.client[socket.id];
The above causes: [Error] TypeError: Cannot read property 'AheT4t9bLxMGoYG9AAAA' of undefined.
Full code:
class Worker extends SCWorker { run() { console.log(' >> Worker PID:', process.pid); var environment = this.options.environment; var app = express(); var httpServer = this.httpServer; var scServer = this.scServer; if (environment === 'dev') { // Log every HTTP request. See https://github.com/expressjs/morgan for other // available formats. app.use(morgan('dev')); } app.use(serveStatic(path.resolve(__dirname, 'public'))); // Add GET /health-check express route healthChecker.attach(this, app); httpServer.on('request', app); socket.on('subscribe', function(channelname){ console.log('subscription completed for ' + channelname + ', ' + socket.id); console.log('All Channels: ' + socket.subscriptions()); console.log('client count : ' + scServer.clientsCount); var serverSocket = scServer.client[socket.id]; if( serverSocket != null) { console.log('Server Socket Found'); } else{ console.log('server socket not found!'); } }) socket.on('disconnect', function () { clearInterval(interval); }); }); } } new Worker();
It should be scServer.clients[socket.id] plural.
scServer.clients[socket.id]
Was never able to find it. Thanks a lot! I'm used to .net IDE & hence intellisense minded ;)
Just trying get a particular socket with id.
The above causes: [Error] TypeError: Cannot read property 'AheT4t9bLxMGoYG9AAAA' of undefined.
Full code: