📜  javascript websocket - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:22.759000             🧑  作者: Mango

代码示例3
// npm install --save ws
const WebSocket = require('ws');

const ws = new WebSocket('ws://www.host.com/path');

ws.on('open', function open() {
  ws.send('something');
});

ws.on('message', function incoming(data) {
  console.log(data);
});