I am trying to emit a socket.io event from my restful api.
My current setup looks something like this:
app.js setups an express app and creates all the necessary routes like:
var app = express();
...
var routesApi = require('./app_api/routes/index');
app.use('/api', routesApi);
module.exports = app;
server.js creates a server and hooks up both express app and socket.io
var http = require('http');
var server = http.createServer(app);
require('../app_server/controllers/socket.js').socketServer(server);
Everything works and I can successfully fire a socket event from the client, process it inside socket.js and emit the results.
However, what I am trying to do is call socket.js method from my restful api and I can't figure out how to hook that up.
Since socket server is initialized inside server.js and my api routing is hooked up in app.js, I am not sure what's the proper way of getting them to talk to each other.
Thank you