From 514ac09fff0ce8ebae66172424d5fe1261f2e645 Mon Sep 17 00:00:00 2001 From: SanaeFox <36219542+Hoshinonyaruko@users.noreply.github.com> Date: Thu, 1 Aug 2024 23:48:54 +0800 Subject: [PATCH] Beta472 (#476) * beta447 * beta448 * beta449 * beta450 * beta451 * beta452 * beta453 * beta454 * beta455 * btea455 * beta456 * beta457 * beta458 * beta460 * beta460 * beta461 * beta462 * beta463 * beta464 * beta465 * beta467 * beta468 * beta469 * beta470 * beta471 * beta472 --- botgo/websocket/client/client.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/botgo/websocket/client/client.go b/botgo/websocket/client/client.go index 099c495b..c1c55275 100644 --- a/botgo/websocket/client/client.go +++ b/botgo/websocket/client/client.go @@ -246,19 +246,22 @@ func (c *Client) readMessageToQueue() { payload.RawMessage = message log.Infof("%s receive %s message, %s", c.session, dto.OPMeans(payload.OPCode), string(message)) - // 计算数据的哈希值 - dataHash := calculateDataHash(payload.Data) + // 不过滤心跳事件 + if payload.OPCode != 11 { + // 计算数据的哈希值 + dataHash := calculateDataHash(payload.Data) + + // 检查是否已存在相同的 Data + if existingPayload, ok := getDataFromSyncMap(dataHash); ok { + // 如果已存在相同的 Data,则丢弃当前消息 + log.Infof("%s discard duplicate message with DataHash: %v", c.session, existingPayload) + continue + } - // 检查是否已存在相同的 Data - if existingPayload, ok := getDataFromSyncMap(dataHash); ok { - // 如果已存在相同的 Data,则丢弃当前消息 - log.Infof("%s discard duplicate message with DataHash: %v", c.session, existingPayload) - continue + // 将新的 payload 存入 sync.Map + storeDataToSyncMap(dataHash, payload) } - // 将新的 payload 存入 sync.Map - storeDataToSyncMap(dataHash, payload) - // 处理内置的一些事件,如果处理成功,则这个事件不再投递给业务 if c.isHandleBuildIn(payload) { continue