ChatMiddleLogic.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. --[[
  2. 跨服聊天
  3. ]]
  4. local Msg = require("core.Msg")
  5. local ObjHuman = require("core.ObjHuman")
  6. local ChatRecord = require("chat.ChatRecord")
  7. local Util = require("common.Util")
  8. local InnerMsg = require("core.InnerMsg")
  9. local MiddleManager = require("middle.MiddleManager")
  10. function getChatMsgFromLogic(fd,msg)
  11. local msgRet = InnerMsg.wl.WL_MIDDLE_CHAT
  12. msgRet.msg = msg.msg
  13. local tb = MiddleManager.SVRINDEX_2_FD
  14. -- 发送协议到连接此中心服的所有本地服
  15. for _,v in pairs(tb) do
  16. InnerMsg.sendMsg(v,msgRet)
  17. end
  18. end
  19. function getChatMsgFromMiddle(fd, msg)
  20. -- 本地记录数据
  21. local chatItem = msg.msg.item
  22. local msgType = chatItem.msgType
  23. -- 普通跨服
  24. if ChatRecord.CHAT_RECORD[msgType] == nil then
  25. ChatRecord.CHAT_RECORD[msgType] = {}
  26. end
  27. local record = ChatRecord.CHAT_RECORD[msgType]
  28. local newTb = Util.copyTable(chatItem)
  29. table.insert(record, newTb)
  30. if #record > ChatRecord.CHAT_RECORD_CNT then
  31. table.remove(record, 1)
  32. end
  33. -- 发送协议聊天记录到跨服频道
  34. Msg.sendWorld(msg.msg)
  35. -- 记录进度
  36. ChatRecord.CHAT_RECORD_JINDU[msgType] = ChatRecord.CHAT_RECORD_JINDU[msgType] or 0
  37. ChatRecord.CHAT_RECORD_JINDU[msgType] = ChatRecord.CHAT_RECORD_JINDU[msgType] + 1
  38. local human = ObjHuman.onlineUuid[msg.msg.item.roleBase.uuid]
  39. if human then
  40. human.db.chatRead = human.db.chatRead or {}
  41. human.db.chatRead[msgType] = human.db.chatRead[msgType] or 0
  42. human.db.chatRead[msgType] = ChatRecord.CHAT_RECORD_JINDU[msgType]
  43. end
  44. end