fix: 倒计时卡住根因修复 — Redis TTL缓冲+前端watchdog兜底
根因:CountdownService用while(sleep(1))阻塞循环推送倒计时, Redis key TTL=wait_time,3台同时运行时worker争用导致循环慢于 Redis过期时间,key先过期→循环中断→倒计时冻结在当前秒数。 修复: 1. Redis TTL加10秒缓冲(waitTime+10),防止key提前过期 2. 前端加watchdog兜底:服务端2秒没推送就本地继续倒计时
This commit is contained in:
@@ -532,9 +532,21 @@ websocket.on('resetBoot',function(data){
|
||||
}
|
||||
}
|
||||
});
|
||||
var _cdTimer = null;
|
||||
var _cdVal = 0;
|
||||
websocket.on('startBetCountDown',function(data){
|
||||
if(data.status == true && data.table_id == table_id){
|
||||
_cdVal = data.count_down;
|
||||
countDown(data.count_down);
|
||||
if(_cdTimer) clearTimeout(_cdTimer);
|
||||
if(_cdVal > 0){
|
||||
_cdTimer = setTimeout(function _tick(){
|
||||
_cdVal--;
|
||||
if(_cdVal >= 0) countDown(_cdVal);
|
||||
if(_cdVal > 0) _cdTimer = setTimeout(_tick, 1000);
|
||||
else _cdTimer = null;
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
websocket.on('endBet',function(data){
|
||||
|
||||
Reference in New Issue
Block a user