作者:用户dvb51bjajs | 来源:互联网 | 2022-10-12 11:16
安装:
npm install ws
服务端(nodejs):
var WebSocketServer = require('ws').Server,
wss = new WebSocketServer({ port: 8080 });
wss.on('connection', function (ws) {
console.log('client connected');
ws.on('message', function (message) {
console.log(message);
});
});
客户端: