0
我使用ws来实现WebSocket服务器,并且我成功发送消息给我的ios客户端(使用SocketRocket )。但是我无法发送消息到服务器或者服务器不能接收来自ios客户端的消息。WebSocket服务器无法接收ios客户端发送的消息
WebSocket伺服器:
const WebSocket = require('ws');
const wss = new WebSocket.Server({port: 8080});
wss.on("connection", function connection(ws) {
ws.on('message,', function incoming(message) {
console.log('received: %s', message);
});
ws.send("something");
});
我希望实现能够与iOS客户端交换数据的WebSocket服务器。
Websocket服务器看起来过于简单,请尝试添加更多事件侦听器并使用console.log输出更多信息。 iOS客户端连接到服务器? – Gntem
是的,客户端收到消息:某事。 – potato