I just want to validate some data with nodejs & socket.io server-side.
So I send the data with socket.emit('validate data', data)
My approach yet is to do it by sending response server-side back like this…
socket.emit('validated data', boolean })
..and get this response on the client-side back like this…
socket.on('validated data', function (boolean) {
validationResponse = boolean;
});
This seems very awkward and inefficiente for just a boolean.
I think this is an very general question about server – client communication with sockets, so a explaination would be very helpful.
Is there a better solution to get a direct response of booleans or tiny information ?
My question was for a shorter or more secure code, but how i suspected with:
.. was there a mistake in thinking about the communication on my side.
The problem is the security isn’t better if you try to protect the application with processes like this, because your client could already fake the returned boolean itself client-side.
So finally i prefer to check it anyway, but if a user send a message with invalid/taken username, the message would not be send to the other clients and the client itself gets an message like
username already taken.buddys, sorry & thanks for your answers.
special thanks to @ThiefMaster