|
|
@@ -4649,11 +4649,16 @@ const createWebSocketConnection = async (type = 1) => {
|
|
|
const isReplay = subType === 1
|
|
|
const timerTypes = ['timer_start', 'timer_pause', 'timer_reset', 'timer_stop', 'timer_finish', 'timer_update']
|
|
|
const writingBoardTypes = ['writing_board_update', 'writing_board_close', 'writing_board_blackboard']
|
|
|
- // 过滤出有效业务消息:不带业务字段的、自己发的、历史重放的 timer_* 全部剔除
|
|
|
+ // 过滤出有效业务消息:不带业务字段的、自己发的、历史重放的 timer_*、超过 30 秒的旧消息 全部剔除
|
|
|
const validObjs = objs.filter((obj: Record<string, any>) => {
|
|
|
if (!obj.type && obj.slideIndex === undefined) return false
|
|
|
if (obj.mId && obj.mId === mId.value) return false
|
|
|
if (isReplay && typeof obj.type === 'string' && obj.type.startsWith('timer_')) return false
|
|
|
+ // 只保留 30 秒内的消息(服务器重放/延迟到达的旧消息忽略)
|
|
|
+ if (obj.timestamp) {
|
|
|
+ const age = Date.now() - new Date(obj.timestamp).getTime()
|
|
|
+ if (age > 30000) return false
|
|
|
+ }
|
|
|
return true
|
|
|
})
|
|
|
// 一次 update 可能带多个 struct(同一 Map 多次 set),只取最后一条处理
|