when I login from a client can not run the function
io.sockets.on('connection', function(socket) {
process.emit('client-connection', socket.id);
// socket.on socket.on('authenticate', function(message) not working
socket.on('authenticate', function(message) {
if (backendSettings.debug) {
console.log('Authenticating client with key "' + message.authToken + '"');
}
authenticateClient(socket, message);
});

socket.on('message', function(message) {
// If the message is from an active client, then process it.
if (io.sockets.sockets[socket.id] && message.hasOwnProperty('type')) {
if (backendSettings.debug) {
console.log('Received message from client ' + socket.id);
}

// If this message is destined for a channel, check that writing to
// channels from client sockets is allowed.
if (message.hasOwnProperty('channel')) {
if (backendSettings.clientsCanWriteToChannels || channelIsClientWritable(message.channel)) {
process.emit('client-message', socket.id, message);
}
else if (backendSettings.debug) {
console.log('Received unauthorised message from client: cannot write to channel ' + socket.id);
}
}

// No channel, so this message is destined for one or more clients. Check
// that this is allowed in the server configuration.
if (backendSettings.clientsCanWriteToClients) {
process.emit('client-message', socket.id, message);
}
else if (backendSettings.debug) {
console.log('Received unauthorised message from client: cannot write to client ' + socket.id);
}
return;
}
});
would you just help
thanks

Comments

teodor.sandu’s picture

Hi, this bug is more than 1 year old, but has no replies. Has anyone identified this as a bug, or could you share with the community how you solved the issue? Thanks

candelas’s picture

I am getting this error too with the last dev. Did any of you solved it?
I have and I can make broadcast messages. I am trying with nodejs_chat module.

  "clientsCanWriteToChannels":true,
  "clientsCanWriteToClients":true,

Thanks for any help :)