public static async Task <TRankPack> RemoteLoadPack(int serverId) { if (serverId < 0) { return(null); } if (RunServerId.Value < 0) { return(null); } return(await RpcProxy.RunAsync(typeof(RankCenterService), RunServerId.Value, RpcProxy.BuildArgs(serverId), () => { if (PKRankPool == null) { Logger.LogError("PKRankPool == null"); return null; } if (COOPRankPool == null) { Logger.LogError("COOPRankPool == null"); return null; } var pack = new TRankPack() { PKList = PKRankPool.GetRange(0, 99), COOPList = COOPRankPool.GetRange(0, 99), }; var pkCount = pack.PKList == null ? 0 : pack.PKList.Count; var coopCount = pack.COOPList == null ? 0 : pack.COOPList.Count; Logger.LogDebug($"[Success]ServerId[{serverId}] load RankPack pkCount[{pkCount}]coopCount[{coopCount}]"); return pack; } )); }
/// <summary> /// 加载榜单数据包 /// </summary> public static ErrorCode LoadPack(int userId, int battleType, int offset, int count, int time, TRankPack output) { if (output == null) { Logger.LogError($"User[{userId}]: Need TRankPack output"); return(ErrorCode.FuncParameterIsNull); } if (PKRankPool == null) { Logger.LogError("PKRankPool== null"); return(ErrorCode.DataNotFound); } if (COOPRankPool == null) { Logger.LogError("COOPRankPool == null"); return(ErrorCode.DataNotFound); } if (time != RankNextLoadTime) { switch ((BattleType)battleType) { case BattleType.PK: output.PKList = PKRankPool.GetRange(offset, count); break; case BattleType.COOP: output.COOPList = COOPRankPool.GetRange(offset, count); break; } output.Time = RankNextLoadTime; } //尝试重新加载所有榜单 _ = TryReloadAllRank(null); return(ErrorCode.Success); }