찾다

 >  Q&A  >  본문

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');
        };
PHPzPHPz2867일 전581

모든 응답(0)나는 대답할 것이다

답장 없음
  • 취소회신하다