如何在也处理RESTful端点的服务器上实现socket.io连接 我的意思是,对于我的应用程序的一个特定地址,用户应该能够像这样进行实时通信
my-app.com/feeds --> this should be capable of real time messaging
所以我的快递服务器是这样设置的
imports here
app.use('/api/users' require('./users'))
app.use('/api/items' require('./items'))
app.listen(PORT, () => console.log('running'))
现在如何使用WebSockets通过socket.io来管理传入连接?我只想要 my-app.com/feeds支持实时通信吗?
我应该像io.use()
那样使用app.use()
吗?
我应该采取什么方法,以便我可以将所有的socket.io连接构造在一个单独的文件中并使用,因为rest是无状态的,而socket.io是有状态的?
我可以使用类似io.use('/api/feeds' do something here)
这样的方法吗?
请指导我