I am trying to build a learning bot for an online internet game. As part of the code we have the following function:
oefTimer: function() {
var start = Date.now();
/*
bot logic
*/
setTimeout(userInterface.oefTimer, (1000 / bot.opt.targetFps) - (Date.now() - start));
},
It's a function I didn't wrote. part of the logic is depends on the ability to send http requests and get responds to them (this is done using $.ajax from JQuery).
Now, the problem is that oefTimer is to fast and sends a lot of http requests, so I wanted to increase the time between each call to a function using setTimeout (so less requests will be sent). but when I did this, when the game ended, some of the requests have never been sent and I got the following error in the console:
WebSocket is already in CLOSING or CLOSED state.
Since in the original code the time between each call to oefTimer considered the Fps of the game, I guesses there is a connection.
How can I solve this problem? my aim is the control the rate of the amount of requests sent per some time unit.
Aucun commentaire:
Enregistrer un commentaire