Open Muzphy opened 5 months ago
var websocketUrl = "ws://172.29.240.1:8111/websocket/message"; var ws = null; var uniqueId = null; run(); console.setExitOnClose(7e3).show(); function run() { try { if (ws == null) { init(); ws = new WebSocket(websocketUrl); ws.send(JSON.stringify({ "binding": uniqueId })); } sleep(1000); } catch (e) { console.log(e); } } ws.on(WebSocket.EVENT_OPEN, (res, ws) => { console.log('open'); console.log(res); }) ws.on(WebSocket.EVENT_MESSAGE, (message, ws) => { console.log('message'); })
代码大致是这样,运行结果是ws可以连接,但是直接打印message而没有打印open 不是很明白为什么ws open的事件没进去 纯纯的新手,希望大家可以不吝赐教 thx
message
open
代码大致是这样,运行结果是ws可以连接,但是直接打印
message
而没有打印open
不是很明白为什么ws open的事件没进去 纯纯的新手,希望大家可以不吝赐教 thx