local Friend_Model = {} local private = {} local EventSystem = require('Event/EventSystem') local friend_opt_pb = require('Proto/friend_opt_pb') local friend_info_pb = require('Proto/friend_info_pb') local black_opt_pb = require('Proto/black_opt_pb') local contact_opt_pb = require('Proto/contact_opt_pb') local search_opt_pb = require('Proto/search_opt_pb') local recommend_opt_pb = require('Proto/recommend_opt_pb') local friend_pb = require('Proto/friend_pb') local Max_Recent_Num = DataSheetManager.ConstData:GetDataByID("RecentContactsNum").IntValue -- 最近上限 local Max_Friend_Num = DataSheetManager.ConstData:GetDataByID("FriendNum").IntValue -- 好友上限 Friend_Model.Max_Black_Num = DataSheetManager.ConstData:GetDataByID("BlacklistNum").IntValue -- 黑名单上限 Friend_Model.ListType = { Recent = 0, --最近列表 Friend = 1, --好友列表 Black = 2, --黑名单 Rival = 3, -- 仇人列表 CrossFriend = 4,--跨服好友 } function Friend_Model.OnStartup() NetManager.RegisterMsgCB(MessageEnums.MessageFriendOperation, nil) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushFriendOperation, private.G2CPushFriendOperation) NetManager.RegisterMsgCB(MessageEnums.MessageInteractivePageRefresh, nil) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushInteractivePage, private.G2CPushInteractivePage) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushInteractivePageChange, private.G2CPushInteractivePageChange) NetManager.RegisterMsgCB(MessageEnums.MessageBlackOperation, nil) NetManager.RegisterMsgCB(MessageEnums.MessageG2CPushBlackOperation, private.G2CPushBlackOperation) NetManager.RegisterMsgCB(MessageEnums.MessageRecentContactMaintenance, nil) NetManager.RegisterMsgCB(MessageEnums.MessagePrecisePlayerSearch, private.PrecisePlayerSearchResp) NetManager.RegisterMsgCB(MessageEnums.MessageFriendsRecommend, private.FriendsRecommendResp) NetManager.RegisterMsgCB(MessageEnums.MessageG2CFriendsActivityRecommendPush, private.FriendsActivityRecommendPush) private.notSendMessage = nil private.privateChatAcid = nil end function Friend_Model.ClearRecordSelectAcids() if Friend_Model.RecordSelectAcids then table.clear(Friend_Model.RecordSelectAcids) end end --未读消息->按照交互时间排序 local function SortByInteractTime(a, b) local isRed_a = CTL.Friend.GetUnreadMsgNum(a.acid) > 0 local isRed_b = CTL.Friend.GetUnreadMsgNum(b.acid) > 0 if isRed_a == isRed_b then return a.interactTimestamp > b.interactTimestamp end return isRed_a end --未读消息->按照是否在线排序 local function SortByOnline(a, b) local isRed_a = CTL.Friend.GetUnreadMsgNum(a.acid) > 0 local isRed_b = CTL.Friend.GetUnreadMsgNum(b.acid) > 0 if isRed_a == isRed_b then if a.isOnline == b.isOnline then if a.isOnline then return a.interactTimestamp < b.interactTimestamp else return a.lastOnlineTimestamp > b.lastOnlineTimestamp end end return a.isOnline end return isRed_a end -- 仇人排序(在线 > 离线, 死敌 > 仇敌, 仇恨值高 > 仇恨值低) local function SortRival(a, b) if a.isOnline and not b.isOnline then return true elseif b.isOnline and not a.isOnline then return false else if a.isSwornEnemy and not b.isSwornEnemy then return true elseif b.isSwornEnemy and not a.isSwornEnemy then return false else return a.hatred > b.hatred end end end --创建数据 function private.GetPlayerInfo(serverPlayerInfo) local info = {} private.SyncPlayerInfo(serverPlayerInfo, info) return info end --更新数据 function private.SyncPlayerInfo(serverPlayerInfo, originInfo) local playerInfo = serverPlayerInfo.PlayerInfo if not playerInfo then playerInfo = serverPlayerInfo end if originInfo then originInfo.acid = playerInfo.PlayerShowInfo.acid originInfo.heroID = playerInfo.PlayerShowInfo.mainHeroId originInfo.name = playerInfo.PlayerShowInfo.name originInfo.level = playerInfo.PlayerShowInfo.level originInfo.isOnline = playerInfo.PlayerShowInfo.isOnline originInfo.lastOnlineTimestamp = playerInfo.PlayerShowInfo.logoutTime originInfo.interactTimestamp = playerInfo.TimeStamp originInfo.power = playerInfo.PlayerShowInfo.gsSum originInfo.guildName = playerInfo.PlayerShowInfo.guildName originInfo.guildID = playerInfo.PlayerShowInfo.guildId originInfo.desEnum = playerInfo.DesEnum originInfo.onlineDays = playerInfo.PlayerShowInfo.onlineDays originInfo.sex = playerInfo.PlayerShowInfo.sex originInfo.vipLv = playerInfo.PlayerShowInfo.vipLv originInfo.showServerId = playerInfo.PlayerShowInfo.ShowServerId originInfo.mergeServerId = playerInfo.PlayerShowInfo.MergeServerId originInfo.officialId = playerInfo.PlayerShowInfo.OfficialId originInfo.soloFightRank = playerInfo.PlayerShowInfo.SoloFightRank originInfo.teamRankID = playerInfo.PlayerShowInfo.teamRankID originInfo.GsRank = serverPlayerInfo.GsRank originInfo.TvTRank = serverPlayerInfo.TvTRank originInfo.ActivePlayer = serverPlayerInfo.ActivePlayer originInfo.BossChallengeRank = serverPlayerInfo.BossChallengeRank -- 通用玩家战斗信息 originInfo.syncBattleMapID = playerInfo.PlayerBattleInfo.SyncBattleMapID -- 同步战斗地图ID originInfo.syncBattleSubID = playerInfo.PlayerBattleInfo.SyncBattleSubID -- 同步战斗的子ID [由各玩法自行填写,含义不同(举例世界Boss为BossID)] originInfo.syncBattleGRoomID = playerInfo.PlayerBattleInfo.SyncBattleGRoomID -- 同步战斗GRoomID(如果玩家在同步战斗中) originInfo.worldBossGuideDone = playerInfo.PlayerBattleInfo.WorldBossGuideDone -- 是否已通关世界BOSS引导本。 -- 以下为仇人扩展(只有不为空的时候才进行刷新赋值) if IsServerDataNotNil(playerInfo.rivalSupplementInfo) then originInfo.isSwornEnemy = playerInfo.rivalSupplementInfo.IsSwornEnemy -- 是否是死敌关系 originInfo.hatred = playerInfo.rivalSupplementInfo.Hatred -- 仇恨值 end originInfo.portraitId = playerInfo.PlayerShowInfo.PortraitId originInfo.frameId = playerInfo.PlayerShowInfo.FrameId originInfo.SyncSoloEloScore = playerInfo.PlayerShowInfo.SyncSoloEloScore originInfo.SyncTvTEloScore = playerInfo.PlayerShowInfo.SyncTvTEloScore --势力徽记信息 originInfo.EmblemFrame = playerInfo.PlayerShowInfo.EmblemFrame originInfo.EmblemContent = playerInfo.PlayerShowInfo.EmblemContent originInfo.isCross = playerInfo.PlayerShowInfo.IsCross -- 玩家所属国家ID originInfo.CountryId = playerInfo.PlayerShowInfo.CountryId originInfo.IsSameWarZone = playerInfo.PlayerShowInfo.IsSameWarZone end end --获取对应类型的未读信息总数 function Friend_Model.GetUnreadMsgNumByType(listType) local redNum = 0 if private.ListDataDic then local dic = private.ListDataDic[listType] if dic then for _, v in pairs(dic) do local num = CTL.Friend.GetUnreadMsgNum(v.acid) redNum = redNum + num end end end if redNum > 99 then --当总数大于99,统一显示99 redNum = 99 end return redNum end --同步列表数据(最近、好友、黑名单、仇人列表) function private.SyncListDataDic(playerInfos, listType, isDataFull) if private.ListDataDic == nil then private.ListDataDic = {} end local isInit = false local dic = private.ListDataDic[listType] if dic == nil then dic = {} private.ListDataDic[listType] = dic isInit = true end if isDataFull then --全量更新,将原有数据全部清除 if isInit == false then table.clear(dic) end for _, v in ipairs(playerInfos) do dic[v.PlayerShowInfo.acid] = private.GetPlayerInfo(v) end else --增量更新,替换旧数据 local friendDic = nil if listType == Friend_Model.ListType.Recent then friendDic = private.ListDataDic[Friend_Model.ListType.Friend] end for _, v in ipairs(playerInfos) do local playerInfo = v.PlayerInfo.PlayerShowInfo local changeType = v.ChangeType local data = dic[playerInfo.acid] if data == nil and listType == Friend_Model.ListType.Friend then data = private.ListDataDic[Friend_Model.ListType.CrossFriend][playerInfo.acid] end if data then if changeType == friend_pb.ChangeRemove or changeType == friend_pb.ChangeRivalRemove then dic[playerInfo.acid] = nil if listType == Friend_Model.ListType.Friend then private.ListDataDic[Friend_Model.ListType.CrossFriend][playerInfo.acid] = nil end else private.SyncPlayerInfo(v.PlayerInfo, data) end else if changeType == friend_pb.ChangeAdd or changeType == friend_pb.ChangeRefresh or changeType == friend_pb.ChangeRivalAdd or changeType == friend_pb.ChangeRivalRefresh or changeType == friend_pb.ChangeRivalRefreshWithSworn then dic[playerInfo.acid] = private.GetPlayerInfo(v.PlayerInfo) end end --好友列表的的部分信息基本上与最近列表是一致的,为了减少推送的数据量,好友列表在刷新最近列表的数据时可以直接复用,减少好友列表的重复数据的推送 if friendDic and friendDic[playerInfo.acid] then friendDic[playerInfo.acid].acid = playerInfo.acid friendDic[playerInfo.acid].heroID = playerInfo.mainHeroId friendDic[playerInfo.acid].name = playerInfo.name friendDic[playerInfo.acid].level = playerInfo.level friendDic[playerInfo.acid].isOnline = playerInfo.isOnline friendDic[playerInfo.acid].lastOnlineTimestamp = playerInfo.logoutTime friendDic[playerInfo.acid].portraitId = playerInfo.PortraitId friendDic[playerInfo.acid].frameId = playerInfo.FrameId end end end Friend_Model.SyncCrossFrined() end --同步本地的申请列表 function private.SyncApplyDic(playerInfos, isDataFull) if private.ApplyDic == nil then private.ApplyDic = {} end if isDataFull then table.clear(private.ApplyDic) for _, v in ipairs(playerInfos) do local acid = v.PlayerInfo.PlayerShowInfo.acid local info = private.ApplyDic[acid] if info then private.SyncPlayerInfo(v, info) else private.ApplyDic[acid] = private.GetPlayerInfo(v) end end else for _, v in ipairs(playerInfos) do local acid = v.PlayerInfo.PlayerInfo.PlayerShowInfo.acid local changeType = v.ChangeType local info = private.ApplyDic[acid] if info then if changeType == friend_pb.ChangeRemove then private.ApplyDic[acid] = nil else private.SyncPlayerInfo(v.PlayerInfo, info) end else if changeType == friend_pb.ChangeAdd or changeType == friend_pb.ChangeRefresh then private.ApplyDic[acid] = private.GetPlayerInfo(v.PlayerInfo) end end end end local isApply = false for _,v in pairs(private.ApplyDic) do if v then isApply = true break end end if isApply then CTL.HomeMain.AddMainNotice(CTL.HomeMain.NoticeType.FriendApply) CTL.RedPoint.AddRedPoint(CTL.RedPoint.RedPointKey.Friend_Apply) else CTL.HomeMain.RemoveMainNotice(CTL.HomeMain.NoticeType.FriendApply) CTL.RedPoint.RemoveRedPoint(CTL.RedPoint.RedPointKey.Friend_Apply) end end function Friend_Model.GetListNum(listType) if private.ListDataDic == nil then return 0 end local num = 0 local typeContainer = private.ListDataDic[listType] if typeContainer then --获取数据 for _, v in pairs(typeContainer) do num = num + 1 end end return num end --根据listType获取排好序的列表(最近、好友、黑名单) function Friend_Model.GetSortedList(listType) if private.ListDataDic == nil then return nil end local typeContainer = private.ListDataDic[listType] if typeContainer then if private.OutputDataList == nil then private.OutputDataList = {} else table.clearArray(private.OutputDataList) end --获取数据 for _, v in pairs(typeContainer) do table.insert(private.OutputDataList, v) end --排序 if listType == Friend_Model.ListType.Recent then table.sort(private.OutputDataList, SortByInteractTime) elseif listType == Friend_Model.ListType.Rival then table.sort(private.OutputDataList, SortRival) else table.sort(private.OutputDataList, SortByOnline) end --移除上限外的数据 if listType == Friend_Model.ListType.Recent then for i = #private.OutputDataList, Max_Recent_Num + 1, -1 do table.remove(private.OutputDataList,i) end elseif listType == Friend_Model.ListType.Friend then for i = #private.OutputDataList, Max_Friend_Num + 1, -1 do table.remove(private.OutputDataList,i) end else for i = #private.OutputDataList, Friend_Model.Max_Black_Num + 1, -1 do table.remove(private.OutputDataList,i) end end return private.OutputDataList end return nil end function Friend_Model.GetApplyInfos() if private.ApplyDic == nil then return nil end if private.OutputDataList == nil then private.OutputDataList = {} else table.clearArray(private.OutputDataList) end for _, v in pairs(private.ApplyDic) do table.insert(private.OutputDataList, v) end --按时间排序 table.sort(private.OutputDataList, SortByInteractTime) return private.OutputDataList end function Friend_Model.GetListTypeNum(listType) local onlineNum = 0 local allNum = 0 local list = Friend_Model.GetSortedList(listType) if list then allNum = #list for _, v in ipairs(list) do if v.isOnline then onlineNum = onlineNum + 1 end end end return onlineNum, allNum end --判断玩家是否在对应类型的列表内 function Friend_Model.IsPlayerInListType(acid, listType) if private.ListDataDic then local typeContainer = private.ListDataDic[listType] if typeContainer then return typeContainer[acid] ~= nil end end return false end -- 获取指定好友玩家信息 function Friend_Model.GetPlayerInListType(acid, listType) if private.ListDataDic then local typeContainer = private.ListDataDic[listType] if typeContainer then return typeContainer[acid] end end return nil end --玩家是否在黑名单中 function Friend_Model.IsPlayerBlack(acid) return Friend_Model.IsPlayerInListType(acid, Friend_Model.ListType.Black) end --玩家是否是好友 function Friend_Model.IsPlayerFriend(acid) return Friend_Model.IsPlayerInListType(acid, Friend_Model.ListType.Friend) or Friend_Model.IsPlayerInListType(acid, Friend_Model.ListType.CrossFriend) end --是否是跨服好友 function Friend_Model.IsCrossPlayerFriend(acid) return Friend_Model.IsPlayerInListType(acid, Friend_Model.ListType.CrossFriend) end -- 玩家是否是仇敌(死敌也算仇敌) function Friend_Model.IsPlayerRival(acid) return Friend_Model.IsPlayerInListType(acid, Friend_Model.ListType.Rival) end -- 玩家是否是死敌 function Friend_Model.IsPlayerRivalSworn(acid) if private.ListDataDic then local typeContainer = private.ListDataDic[Friend_Model.ListType.Rival] if typeContainer then local rivalData = typeContainer[acid] if rivalData then return rivalData.isSwornEnemy end end end return false end function Friend_Model.IsCrossPlayer(acid) if private.ListDataDic then for k,v in pairs( private.ListDataDic) do if v[acid] then return v[acid].isCross end end end return false end function Friend_Model.IsSameWarZone(acid) if private.ListDataDic then for k, v in pairs(private.ListDataDic) do if v[acid] then return v[acid].IsSameWarZone end end end return false end function Friend_Model.SyncCrossFrined() local list = private.ListDataDic[Friend_Model.ListType.Friend] if private.ListDataDic[Friend_Model.ListType.CrossFriend] == nil then private.ListDataDic[Friend_Model.ListType.CrossFriend] = {} end local crossList = private.ListDataDic[Friend_Model.ListType.CrossFriend] if list == nil then return end for k,v in pairs(list) do if v.isCross then crossList[v.acid] = v list[k] = nil end end end function Friend_Model.SaveNotSendState(privateChatAcid, notSendMessage) private.privateChatAcid = privateChatAcid private.notSendMessage = notSendMessage end function Friend_Model.GetLastPrivateChatAcid() return private.privateChatAcid end function Friend_Model.GetNotSendMessage() return private.notSendMessage end --region 协议相关 --好友操作 function private.FriendOperationReq(acid, optType, desEnum) local msg = friend_opt_pb.FriendOperationReq() msg.TargetACID = acid msg.OptType = optType msg.DesEnum = desEnum or 0 NetManager.SendMessage(MessageEnums.MessageFriendOperation, msg) end --发起好友申请 function Friend_Model.SendApplyFriend(acid, desEnum) private.FriendOperationReq(acid, friend_opt_pb.FriendOptSendApplication, desEnum) end --删除已有好友 function Friend_Model.SendDeleteFriend(acid) private.FriendOperationReq(acid, friend_opt_pb.FriendOptRemoveFriend) end --同意好友申请 function Friend_Model.SendAgreeFriendApply(acid) private.FriendOperationReq(acid, friend_opt_pb.FriendOptAgreeApplication) end --忽略好友申请 function Friend_Model.SendDegreeFriendApply(acid) private.FriendOperationReq(acid, friend_opt_pb.FriendOptDegreeApplication) end --同意所有申请 function Friend_Model.SendAgreeAllFriendApply() private.FriendOperationReq("", friend_opt_pb.FriendOptAgreeAllApplication) end --忽略所有申请 function Friend_Model.SendDegreeAllFriendApply() private.FriendOperationReq("", friend_opt_pb.FriendOptDegreeAllApplication) end --处理好友执行 function private.G2CPushFriendOperation(msgResp) logging.log(LTAG.LOG, "G2CPushFriendOperation") if msgResp.Success then if msgResp.OptType == friend_opt_pb.FriendOptSendApplication then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_Apply) elseif msgResp.OptType == friend_opt_pb.FriendOptRemoveFriend then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_Delete) elseif msgResp.OptType == friend_opt_pb.FriendOptAgreeApplication then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_AddFriend) elseif msgResp.OptType == friend_opt_pb.FriendOptAgreeAllApplication then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_AlreadyAllAgree) end else local type = msgResp.FailType local optType = msgResp.OptType if type == friend_opt_pb.FailHasBecomeFriend then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_AlreadyFriend) elseif type == friend_opt_pb.FailInTargetEnemy then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_HisBlacklist1) elseif type == friend_opt_pb.FailInSelfEnemy then if optType == friend_opt_pb.FriendOptSendApplication or optType == friend_opt_pb.FriendOptAgreeApplication then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_JoinBlacklist3) end elseif type == friend_opt_pb.FailSelfFriendNumLimit then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_FriendNumLimit) elseif type == friend_opt_pb.FailTargetFriendNumLimit then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_HisFriendNumLimit) elseif type == friend_opt_pb.FailSendTargetApplicationNumLimit then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_HisFriendApplyLimit) elseif type == friend_opt_pb.FailRemoveNotBecomeFriend then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_NotInFriendsList) elseif type == friend_opt_pb.FailSelfCrossFriendNumLimit then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_FriendCrossNumLimit) elseif type == friend_opt_pb.FailTargetCrossFriendNumLimit then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_HisFriendCrossNumLimit) end end end function private.InteractivePageRefreshReq(pageType) local msg = friend_info_pb.InteractivePageRefreshReq() msg.PageType = pageType NetManager.SendMessage(MessageEnums.MessageInteractivePageRefresh, msg) end --请求刷新申请列表 function Friend_Model.SendRefreshApplyInfos() private.InteractivePageRefreshReq(friend_info_pb.PageFriendApplication) end --请求刷新好友列表 function Friend_Model.SendRefreshFriendInfos() private.InteractivePageRefreshReq(friend_info_pb.PageFriend) end --请求刷新黑名单列表 function Friend_Model.SendRefreshBlackInfos() private.InteractivePageRefreshReq(friend_info_pb.PageEnemy) end --请求刷新最近列表 function Friend_Model.SendRefreshRecentInfos() private.InteractivePageRefreshReq(friend_info_pb.PageContact) end -- 请求刷新仇人列表 function Friend_Model.SendRefreshRivalInfos() private.InteractivePageRefreshReq(friend_info_pb.PageRival) end --刷新列表信息(主动请求,全量更新) function private.G2CPushInteractivePage(msgResp) logging.log(LTAG.LOG, "G2CPushInteractivePage", msgResp ) if msgResp.NeedRefreshFriendApplication then --申请页列表 private.SyncApplyDic(msgResp.PlayerFriendApplications, true) end if msgResp.NeedRefreshFriend then --好友列表 private.SyncListDataDic(msgResp.PlayerFriendInfos, Friend_Model.ListType.Friend, true) end if msgResp.NeedRefreshBlack then --黑名单列表 private.SyncListDataDic(msgResp.PlayerBlackInfos, Friend_Model.ListType.Black, true) end if msgResp.NeedRefreshContact then --最近列表 private.SyncListDataDic(msgResp.PlayerContactInfos, Friend_Model.ListType.Recent, true) end if msgResp.NeedRefreshRival then -- 仇人列表 private.SyncListDataDic(msgResp.PlayerRivalInfos, Friend_Model.ListType.Rival, true) EventSystem.Dispatch(EventID.UI_Rival_RefreshRivalList) end EventSystem.Dispatch(EventID.UI_UpdateFriendInfo) end --刷新列表信息(服务器推送,增量更新) function private.G2CPushInteractivePageChange(msgResp) logging.log(LTAG.LOG, "G2CPushInteractivePageChange", msgResp) if IsServerDataNotNil(msgResp.PlayerFriendApplicationsChange) then --申请页列表 private.SyncApplyDic(msgResp.PlayerFriendApplicationsChange, false) end if IsServerDataNotNil(msgResp.PlayerFriendChangeInfos) then --好友列表 private.SyncListDataDic(msgResp.PlayerFriendChangeInfos, Friend_Model.ListType.Friend, false) end if IsServerDataNotNil(msgResp.PlayerContactChangeInfos) then --最近列表 private.SyncListDataDic(msgResp.PlayerContactChangeInfos, Friend_Model.ListType.Recent, false) end if IsServerDataNotNil(msgResp.PlayerBlackChangeInfos) then --黑名单列表 private.SyncListDataDic(msgResp.PlayerBlackChangeInfos, Friend_Model.ListType.Black, false) EventSystem.Dispatch(EventID.UI_UpdateBlack) EventSystem.Dispatch(EventID.UI_UpdateChatRed) end if IsServerDataNotNil(msgResp.PlayerRivalChangeInfos) then -- 仇人列表 private.SyncListDataDic(msgResp.PlayerRivalChangeInfos, Friend_Model.ListType.Rival, false) EventSystem.Dispatch(EventID.UI_Rival_RefreshRivalList) end EventSystem.Dispatch(EventID.UI_UpdateFriendInfo) end --黑名单操作 function Friend_Model.BlackOperationReq(acid, isAdd) local msg = black_opt_pb.BlackOperationReq() msg.TargetACID = acid msg.Add = isAdd NetManager.SendMessage(MessageEnums.MessageBlackOperation, msg) end function private.G2CPushBlackOperation(msgResp) logging.log(LTAG.LOG, "G2CPushBlackOperation") if msgResp.Success then if msgResp.Add == false then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_IfDeleteBlacklist2) -- 已将该玩家移除黑名单 else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_JoinBlacklist2) -- 已将该玩家加入黑名单 end else if msgResp.FailType == black_opt_pb.FailAddSelfBlackNumLimit then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Friend_BlacklistNumList) end end end --维护最近联系人 function Friend_Model.RecentContactMaintenanceReq(acid) local msg = contact_opt_pb.RecentContactMaintenanceReq() msg.TargetACID = acid NetManager.SendMessage(MessageEnums.MessageRecentContactMaintenance, msg) end --精确搜索 function Friend_Model.PrecisePlayerSearchReq(searchStr) local msg = search_opt_pb.PrecisePlayerSearchReq() msg.PlayerInfo = searchStr NetManager.SendMessage(MessageEnums.MessagePrecisePlayerSearch, msg) end function private.PrecisePlayerSearchResp(msgResp) logging.log(LTAG.LOG, "PrecisePlayerSearchResp") if msgResp.Resp.Code == 0 then EventSystem.Dispatch(EventID.UI_UpdateFriendSearch, msgResp.PlayerInfo) end end function private.G2CPushPrecisePlayerSearch(msgResp) logging.log(LTAG.LOG, "G2CPushPrecisePlayerSearch") end --获取推荐列表 function Friend_Model.FriendsRecommendReq(needReset, isCD, optType) local optType = optType or 0 if isCD then Friend_Model.RecommendRequestTime = UTL.Time.GetServerTimestamp() else Friend_Model.RecommendRequestTime = nil end local msg = recommend_opt_pb.FriendsRecommendReq() msg.NeedReset = needReset msg.OptType = optType NetManager.SendMessage(MessageEnums.MessageFriendsRecommend, msg) end --按照是否在线排序 local function FriendsRecommendSortByOnline(a, b) local infoA = a.PlayerInfo.PlayerShowInfo local infoB = b.PlayerInfo.PlayerShowInfo if infoA.isOnline == infoB.isOnline then if infoA.isOnline then return infoA.logoutTime < infoB.logoutTime else return infoA.logoutTime > infoB.logoutTime end end return infoA.isOnline end function private.FriendsRecommendResp(msgResp) logging.log(LTAG.LOG, "FriendsRecommendResp") if msgResp.Resp.Code == 0 then Friend_Model.CacheRecommendPlayerInfos = msgResp.PlayerInfos table.sort(Friend_Model.CacheRecommendPlayerInfos, FriendsRecommendSortByOnline) EventSystem.Dispatch(EventID.UI_UpdateFriendRecommend, msgResp.PlayerInfos) end end function private.FriendsActivityRecommendPush(msg) logging.log(LTAG.LOG, "MessageG2CFriendsActivityRecommendPush") --添加延时打开推荐好友主城显示的界面 CTL.HomeMain.AddTownHomeDelayView(Const_UI_Lua.UIEnum.UIFriendRecommend, {playerId = msg.RecommendACID, name = msg.RecommendName, recommendType = msg.DesEnum, sex = msg.sex}) end --endregion return Friend_Model