问题描述
const WebSocket = require("ws");
const wss = new WebSocket.Server({ port: 8082 });
wss.on("connection",(ws) => {
console.log("New client connected!");
ws.on("message",(data) => {
console.log("Client has sent us: ${data}");
});
//ws.send(data.toUpperCase());
ws.on("close",() => {
console.log("Client has disconnected!");
});
});
此处,该消息显示在localhost下的dev tools网络面板上。但是,在节点终端中,它显示为客户端已向我们发送:$ {data},而预期的结果是客户端已向我们发送了:无论客户端发送的消息是什么。 我将随附终端的屏幕截图。预先感谢。Image of the terminal
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)