I have my Node.js script using socket.io. I understand how it works when the server answer to a client message. What I want to do it's that the server sends messages on his own when the execution of a function is over. I don't know how to proceed, can you help me ?
Here is my code :
function myfunction(){
// instructions
setTimeout(function(){
otherfunction(function(ans){
/*
I want to send a message via socket.io over here
*/
});
myfunction();
}, 30000);
}
var server=https.createServer(options, function (req, res) {
// instructions
}.listen(443);
var io=require('socket.io').listen(server, {log:false});
io.sockets.on('connection', function(socket){
socket.on('request', function(msg){
// instructions
});
});
It will be very good if you can help me doing this. Thank you for your help.