From fbfb02fc34d3b82de65292d6026240e5eeb83be9 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Sat, 27 Mar 2021 14:58:57 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=81=8A=E5=A4=A9=E3=80=91=E5=85=AC?= =?UTF-8?q?=E4=BC=9A=E6=B6=88=E6=81=AF=E7=BC=93=E5=AD=98=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=EF=BC=8C=E6=9A=82=E6=97=B6=E5=88=A0=E9=99=A4=E5=85=AC=E4=BC=9A?= =?UTF-8?q?=E7=BA=A2=E5=8C=85=E8=B7=91=E9=A9=AC=E7=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Modules/Chat/ChatManager.lua | 65 ++++++++----------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Chat/ChatManager.lua b/Assets/ManagedResources/~Lua/Modules/Chat/ChatManager.lua index 8e1cccaeea..99da53e00e 100644 --- a/Assets/ManagedResources/~Lua/Modules/Chat/ChatManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Chat/ChatManager.lua @@ -15,6 +15,7 @@ local _DeltaTime = 5 -- 定时刷新数据的通道枚举 local _CHANNEL = { CHAT_CHANNEL.SYSTEM, -- 系统 + CHAT_CHANNEL.FAMILY, -- CHAT_CHANNEL.GLOBAL, -- 世界 } this.SYS_MSG_TYPE = { @@ -161,14 +162,14 @@ function this.RequestSendChatMsg(channel, content, func) if func then func() end else __DebugLog(Language[10357]) - if channel == CHAT_CHANNEL.FAMILY then - if func then func() end - else + -- if channel == CHAT_CHANNEL.FAMILY then + -- if func then func() end + -- else NetManager.RequestChatMsg(channel, msgId, function(data) this.ChatDataAdapter(channel, data) if func then func() end end) - end + -- end end end) end @@ -201,6 +202,7 @@ end -- 数据处理 function this.ChatDataAdapter(channel, data) + __DebugLog("ChatDataAdapter++++++++++++++++++++++++++++++"..channel) -- 好友数据特殊处理 if channel == CHAT_CHANNEL.FRIEND then return end -- 先对数据排个序 @@ -214,38 +216,6 @@ function this.ChatDataAdapter(channel, data) -- 数据没有变化,则不刷新 local len = #data.chatInfo if len == 0 then return end - --- 公会数据无需判断消息号 - if channel == CHAT_CHANNEL.FAMILY then - __DebugLog("++++++++++++++++++++++++++++++"..channel) - for i = 1, len do - table.insert(this.ChatList[channel], data.chatInfo[i]) - __DebugLog(Language[10359]..data.chatInfo[i].msg) - -- 公会红包消息加入跑马灯显示 - local anaMsg = string.split(data.chatInfo[i].msg, "#") - local msgType = tonumber(anaMsg[1]) - if msgType == GLOBAL_CHAT_TYPE.GUILD_REDPACKET then - local content = this.AnalysisGlobalChat(data.chatInfo[i].msg).content - local race = { - messageId = 0, - msg = content, - speed = this.horseRunSpeed, - multiple = 1, - } - HorseRaceManager.AddRaceData(race) - - Log("ChatManager") - -- if GuildRedPacketManager.isCheck then return end - GuildRedPacketManager.isCheck=true - CheckRedPointStatus(RedPointType.Guild_RedPacket) - end - end - __DebugLog("++++++++++++++++++++++++++++++"..channel) - -- 更新事件 - Game.GlobalEvent:DispatchEvent(GameEvent.Chat.OnChatDataChanged, channel) - return - end - - --- 非公会 --- 判断messageId是否符合要求,新数据得第一条messageId必须比旧数据最后一条大, --- mssageId相等表示包含敏感字未发出的消息,此消息需要在前端展示,但是不会发送给其他人 __DebugLog("++++++++++++++++++++++++++++++"..channel) @@ -255,6 +225,7 @@ function this.ChatDataAdapter(channel, data) local msgIdFlag = this.GetMsgIdFlag(channel) -- 获取当前最新消息号 __DebugLog("--") LogGreen("消息内容:"..newChat.msg) + LogGreen("消息类型:"..newChat.messageType) LogGreen("本地最新消息"..msgIdFlag..",新消息的消息号:"..newMsgId) local msgStr = string.split(newChat.msg,"|") if channel == CHAT_CHANNEL.SYSTEM then @@ -277,6 +248,22 @@ function this.ChatDataAdapter(channel, data) tostring(msgStr[5]), tostring(msgStr[6]) ) + elseif channel == CHAT_CHANNEL.FAMILY then + local msgs = string.split(newChat.msg,"#") + -- 公会红包的消息需要处理一下 + local msgType = tonumber(msgs[1]) + if msgType == GLOBAL_CHAT_TYPE.GUILD_REDPACKET then + if tonumber(newChat.times) > this.LoginTimeStamp then + -- 公会红包暂时不再显示跑马灯 + -- newChat.msg = this.AnalysisGlobalChat(newChat.msg).content + -- newChat.messageType = 8 -- 公会红包的类型 + -- newChat.speed = this.horseRunSpeed + -- newChat.multiple = 1 + + GuildRedPacketManager.isCheck = true + CheckRedPointStatus(RedPointType.Guild_RedPacket) + end + end end LogGreen("消息内容:"..newChat.msg) if msgIdFlag < newMsgId or newMsgId == -1 then @@ -284,8 +271,8 @@ function this.ChatDataAdapter(channel, data) if newMsgId ~= -1 then -- 消息号为-1表示屏蔽消息,保存数据但不保存消息号, this.SetMsgIdFlag(channel, newMsgId) -- 保存当前消息的消息号,避免下次刷新时还会请求 end - -- __DebugLog(Language[10363]..tostring(tonumber(newChat.times) <= this.LoginTimeStamp)) - -- if tonumber(newChat.times) > this.LoginTimeStamp - 7200000 then -- 登录时间之前的消息都不显示 + __DebugLog(Language[10363]..tostring(tonumber(newChat.times) <= this.LoginTimeStamp)) + if channel ~= CHAT_CHANNEL.SYSTEM or tonumber(newChat.times) > this.LoginTimeStamp then -- 登录时间之前的系统消息都不显示 if channel ~= CHAT_CHANNEL.SYSTEM or this.IsShowInChatPanel(newChat.messageType) then if not GoodFriendManager.IsInBlackList(newChat.senderId) then -- 判断是否在黑名单中 table.insert(this.ChatList[channel], newChat) @@ -298,7 +285,7 @@ function this.ChatDataAdapter(channel, data) if this.IsShowInHorseRace(newChat.messageType) then HorseRaceManager.AddRaceData(newChat) end - -- end + end end __DebugLog("--") end