Rumah > Soal Jawab > teks badan
服务端(用的ws,node.js)发送了一个ping事件但是客户端这里的onping却没有触发,这是为什么啊?
//server
wss.on("connection", function connection(ws) {
ws.on('message', function(message) {
console.log('received: %s', message);
});
ws.ping('ping');
});
//client
ws.onping = function () {
console.log('receive ping');
};