Reputation: 51
I am attempting to use node.js to create a login script. The user enters their information on a page and they are redirected to a validation page. The server than checks against a users database and confirms all the login info is matching.
The server then takes the client's socket and emits in this code:
function emitverified(dbuser) {
console.log(dbuser);
io.to(dbuser).emit('l');
}
The client handles this in this code
socket.on('l', function () {
console.log("Validation occurred successfully");
});
At this time, the client is not receiving the l signal that is emitted.
Upvotes: 0
Views: 68
Reputation: 1031
.to
broadcast to a room
. Join your client socket
to dbuser
first.
socket.join(dbuser);
server.to(dbuser).emit('l');
Upvotes: 1