Configuring Express 4.0 routes with socket.io

前端 未结 3 648
渐次进展
渐次进展 2021-01-31 22:33

I have created a new Express application. It generated app.js for me and I have then created the following index.js bringing in socket.io:

var app = require(\'./         


        
3条回答
  •  梦谈多话
    2021-01-31 22:52

    I think a better way to do it is to attach the Io server to response object In the first middleware .per the way express is designed the Io server will be available to your subsequent routes.

    Check this link

提交回复
热议问题