【发布时间】:2015-09-22 13:40:07
【问题描述】:
这是我到目前为止所得到的,我正在尝试找到一个解决方案,以便:
- 连接始终保持活动状态,因此我可以处理状态更新
- 我可以使用来自 POST 请求的数据向客户端发送 websocket 消息
wsapi here
router.post('/', function (req, res) {
// Need to send ws.send() with post data
})
wss.on('connection', function(ws) {
ws.on('message', function(message) {
console.log('r : %s', message);
});
// ws is only defined under this callback as an object of type ws
});
【问题讨论】: