search

Home  >  Q&A  >  body text

node.js - onping事件不能触发

服务端(用的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');
        };
PHPzPHPz2785 days ago538

reply all(0)I'll reply

No reply
  • Cancelreply