UILiveRoom:聊天数据
This commit is contained in:
parent
206abfb58e
commit
875ea92894
@ -1,5 +1,7 @@
|
||||
local LiveRoomData = class("LiveRoomData", require("DataBase"))
|
||||
|
||||
local CONST_MAX_CHAT_DATA_NUM = 50
|
||||
|
||||
function LiveRoomData:ctor()
|
||||
self.data = {}
|
||||
end
|
||||
@ -25,7 +27,20 @@ function LiveRoomData:RegisterNetEvents()
|
||||
end
|
||||
end)
|
||||
|
||||
-- uint64 uid = 1;
|
||||
-- uint32 room_id = 2;
|
||||
-- LiveRoomChatData chat_data = 3;
|
||||
-- message LiveRoomChatData {
|
||||
-- uint64 SN = 1;
|
||||
-- LiveRoomPlayerInfo player_info = 2;
|
||||
-- string chat_content = 3;
|
||||
-- }
|
||||
ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_LIVE_ROOM_CHAT_NTF, function(data)
|
||||
self.data.chatDataSN = data["chat_data"].SN
|
||||
local idx = self.data.chatDataSN % CONST_MAX_CHAT_DATA_NUM + 1
|
||||
self.data.chatData = self.data.chatData or {}
|
||||
self.data.chatData[idx] = data["chat_data"]
|
||||
ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_FRUIT_CHAT_NTF, true)
|
||||
end)
|
||||
|
||||
ManagerContainer.NetManager:NetRegister(ProtoMsgId.SC_LIVE_ROOM_SEND_GIFT_ACK, function(data)
|
||||
@ -104,6 +119,27 @@ function LiveRoomData:GetData()
|
||||
return self.data
|
||||
end
|
||||
|
||||
function LiveRoomData:GetChatData(count)
|
||||
count = count or 20
|
||||
if not self.data.chatDataSN then
|
||||
return {}
|
||||
end
|
||||
local sn = self.data.chatDataSN
|
||||
local chatData = {}
|
||||
self.data.chatData = self.data.chatData or {}
|
||||
for i = 1, CONST_MAX_CHAT_DATA_NUM do
|
||||
local idx = sn % CONST_MAX_CHAT_DATA_NUM + 1
|
||||
if self.data.chatData and self.data.chatData[idx] then
|
||||
table.insert(chatData, self.data.chatData[idx])
|
||||
if #chatData > count then
|
||||
break
|
||||
end
|
||||
end
|
||||
sn = sn - 1
|
||||
end
|
||||
return chatData
|
||||
end
|
||||
|
||||
function LiveRoomData:JoinReq(room_type)
|
||||
ManagerContainer.NetManager:SendMessage(ProtoMsgId.CS_LIVE_ROOM_JOIN_REQ, {room_type=room_type})
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user