【发布时间】:2018-10-25 12:38:49
【问题描述】:
在我继承的代码中使用了this websocket。我阅读了文档并进行了大量谷歌搜索,以找到 websocketServer 如何向客户端(浏览器)发出消息。这是一个代码sn-p:
var wsServer = new WebSocketServer({
httpServer: server,
autoAcceptConnections: false,
path:"/async" //This attribute is not in the documentation
});
wsServer.on('request', function(request) {
var connection = request.accept('relay_protocol', request.origin);
connection.on('message', function(message) {
....
});
});
我找不到connection 对象的文档。它有什么特性?
最后,使用什么方法将消息发送回客户端?
总的来说,为这个模块提供的信息很差。请帮忙。
【问题讨论】:
标签: javascript node.js websocket