Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

To init socket.io you need some crucial things, like the server var that is init in app.js file. So, if you try to require socket.io out of app.js and you try to init socket.io, then you could have some troubles. Because socket.io can't be init without the server var in your case.

If you try to require socket.io and not init it. I think you will have not problem. So try to understand the section that is related to Express in the socket.io documentation : http://socket.io/docs/#

Then you can try to use the npm module for express and socket.io : http://express-io.org/

Or you can deal with socket.of() method : http://socket.io/docs/rooms-and-namespaces/#

In any event, you should init socket.io with the server var. So, you can make your module to manage socket.io behavior, define some methods, etc. For this purpose, you can passe socket.io in argument to your route files. See here :Use socket.io inside a express routes fileUse socket.io inside a express routes file Then, that logic allow you to use socket.io anywhere in your app.

To init socket.io you need some crucial things, like the server var that is init in app.js file. So, if you try to require socket.io out of app.js and you try to init socket.io, then you could have some troubles. Because socket.io can't be init without the server var in your case.

If you try to require socket.io and not init it. I think you will have not problem. So try to understand the section that is related to Express in the socket.io documentation : http://socket.io/docs/#

Then you can try to use the npm module for express and socket.io : http://express-io.org/

Or you can deal with socket.of() method : http://socket.io/docs/rooms-and-namespaces/#

In any event, you should init socket.io with the server var. So, you can make your module to manage socket.io behavior, define some methods, etc. For this purpose, you can passe socket.io in argument to your route files. See here :Use socket.io inside a express routes file Then, that logic allow you to use socket.io anywhere in your app.

To init socket.io you need some crucial things, like the server var that is init in app.js file. So, if you try to require socket.io out of app.js and you try to init socket.io, then you could have some troubles. Because socket.io can't be init without the server var in your case.

If you try to require socket.io and not init it. I think you will have not problem. So try to understand the section that is related to Express in the socket.io documentation : http://socket.io/docs/#

Then you can try to use the npm module for express and socket.io : http://express-io.org/

Or you can deal with socket.of() method : http://socket.io/docs/rooms-and-namespaces/#

In any event, you should init socket.io with the server var. So, you can make your module to manage socket.io behavior, define some methods, etc. For this purpose, you can passe socket.io in argument to your route files. See here :Use socket.io inside a express routes file Then, that logic allow you to use socket.io anywhere in your app.

Source Link
laudeon
  • 190
  • 12

To init socket.io you need some crucial things, like the server var that is init in app.js file. So, if you try to require socket.io out of app.js and you try to init socket.io, then you could have some troubles. Because socket.io can't be init without the server var in your case.

If you try to require socket.io and not init it. I think you will have not problem. So try to understand the section that is related to Express in the socket.io documentation : http://socket.io/docs/#

Then you can try to use the npm module for express and socket.io : http://express-io.org/

Or you can deal with socket.of() method : http://socket.io/docs/rooms-and-namespaces/#

In any event, you should init socket.io with the server var. So, you can make your module to manage socket.io behavior, define some methods, etc. For this purpose, you can passe socket.io in argument to your route files. See here :Use socket.io inside a express routes file Then, that logic allow you to use socket.io anywhere in your app.