How to block sending socket.emit on browser ?
server
io.on('connection', function (socket) {
socket.on('singupCheck', function (msg) {
console.log(msg);
});
});
Browser console
var socket = io();
socket.emit('singupCheck','test');
I think you can't block emit
function on socket.io
in the console.
But, for example, you can check data on the Node.js
side and then decide what you need to do.
For example:
socket.on('event', (data) => {
if (!data) {
throw new Error('Empty data');
}
//do something
});
For this case you will secure your event for empty data. Also you can check type of expected data.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.