My sio = require('socket.io').listen(app)
is in my server.js file, but I'm calling a method in a library that would like to push a message to the client... say api.user.pushToClient()
How am I able to access sio.sockets
from there? Perhaps my structure is incorrect?
Folder structure:
server.js
api
|--user.js
|--another.js
in server.js
append this line
module.exports.sio = sio;
in api/user.js
sio = require('../server').sio;
sio.sockets.on ...
Or did I misunderstand the question?