我希望拦截从接收器角度发送的某些消息。这意味着,例如:
有没有人知道在socket.io中需要更改哪部分代码才能实现?我一直在搜索模块:适配器,客户端,解析器......但没有发现任何相关的......对这个有什么想法?我已经有点绝望了xp
答案 0 :(得分:0)
服务器端:
socket.on("chat", clientMsg);
function clientMsg(data){
console.log("data received:" + data)
var msg = data; // set the msg to be sent
// treat the data server side or
// if wanting to treat the data from the user's side
// create another socket.on() inside this function. to treat it remotely (if needed)
// then, when finished send the message to all users with the treated data.
io.sockets.emit("chat", msg)
};