if i do
socket.emit("eventname",data);
I am emitting an event to socket. if I want filter this emission i would attach a function and use this function
function emit(socket,eventname,data)
{
.. // process event data
socket.emit(eventname,data); // emiting processed
}
but I want to overwrite the object in some way to generically all output (and input events data) to be processed or modified conveniently, as for example trimming strings of the objects. O also would add an filter for syntactic exception to avoid wrong formatted json that can collapse the process or a injection filter...
How to do it without directly modifying socket.io code but rewriting somehow. Sorry if this question is stupid.
You can just redefine socket.emit
socket.__emit = socket.emit
socket.emit = function (channel, data) {
//process data;
socket.__emit(channel, data);
};