为什么 node.js 在尝试在本地主机上运行应用程序时需要升级? [英] Why node.js requires an upgrade while trying to run an application on the localhost?
问题描述
当我尝试在 localhost 服务器上运行我的 node.js 应用程序时,它无法运行并需要进行必要的升级.我试图运行代码,但出现以下错误:
服务器代码
var WebSocketServer = require('ws').Server,ws = new WebSocketServer({port: 80}),客户=[];**新的连接建立**ws.on('connection', function(conn) {CLIENTS.push(conn);conn.on('message', function(message) {console.log('收到:%s', message);发送所有(消息);});console.log("新连接");conn.send("新客户端连接");**如果你关闭连接**conn.on('关闭', function() {console.log("连接关闭");CLIENTS.splice(CLIENTS.indexOf(conn), 1);});});**向所有客户端发送消息**函数 sendAll(消息){for (var i=0; i
客户端代码
结果:<output name="" type="text" id="result" value"readonly"></output></p><input type="text" onchange="ws.send(this.value);">