Wednesday, 7 June 2017

Test if a function runs in the past minute or second javascript

I'm using socket.io with a node.js server in communication between clients, and in receiving message from one client I do some treatment in the callback and i have some code that run every time and some that must run once a minute to store data in a mysql database:

io.on('connection', function(socket) {
       socket.on('createroom', function(room) {
                socket.on('values', function(values) {
                        treatment done each time with values;
                        treatment must be done once a minute with values;
                }
       }
}

How I can test if a function or some code has run in the past minute.



via omar bouzoumita

No comments:

Post a Comment