MajsoulPaipuAnalyzer icon indicating copy to clipboard operation
MajsoulPaipuAnalyzer copied to clipboard

fix: limit query rate of GameData.

Open zyr17 opened this issue 3 months ago • 0 comments

let lastCallbackTime = 0;

ipcr.on('fetchpaipudata', (event, uuid, callback = 'fetchpaipudatacallback') => {
    console.log('fetching paipu, uuid=' + uuid);
    
    app.NetAgent.sendReq2Lobby("Lobby", "fetchGameRecord", {
        game_uuid: uuid,
        client_version_string: GameMgr.prototype.getClientVersion()
    }, function (t, a) {
        const currentTime = Date.now();
        const delay = Math.max(0, 1000 - (currentTime - lastCallbackTime));

        setTimeout(() => {
            ipcr.send(callback, uuid, a);
        }, delay);

        lastCallbackTime = currentTime;
    });
});

zyr17 avatar Nov 03 '24 09:11 zyr17