forked from powerfun/udpservice
修复异常导致的所有虚拟人物都骑行完毕,数据没有加载的问题。
This commit is contained in:
parent
98781ecd58
commit
6921145154
@ -13,15 +13,19 @@ namespace OnlineUserPool.Hander
|
||||
public class MapRecordRankingHander
|
||||
{
|
||||
private static List<MapRecordRanking> mapRecordRankings;
|
||||
private static bool loading = false;//防止服务端响应慢,多次加载
|
||||
private static object locker = new object();//防止服务端响应慢,多次加载
|
||||
private int top = int.Parse(ConfigHelp.Top);
|
||||
|
||||
public MapRecordRankingHander()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
var randomUser = WebService.GetMapRouteRandomUser(new RandomRankingUserRequestVM() { top = top });
|
||||
mapRecordRankings = WebService.GetRecordFileFromServer(randomUser.Select(n => n.RankingId).ToList());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取虚拟人物数据
|
||||
/// </summary>
|
||||
@ -72,10 +76,13 @@ namespace OnlineUserPool.Hander
|
||||
/// </summary>
|
||||
public void RemoveEndAndAddNewVirtualUser()
|
||||
{
|
||||
if (mapRecordRankings != null && mapRecordRankings.Count > 0 && !loading)
|
||||
lock (locker)
|
||||
{
|
||||
loading = true;
|
||||
var end = mapRecordRankings.FindAll(n => n.End);
|
||||
if (end.Count == mapRecordRankings.Count)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
if (end.Count > 0)
|
||||
{
|
||||
mapRecordRankings.RemoveAll(n => n.End);
|
||||
@ -87,7 +94,6 @@ namespace OnlineUserPool.Hander
|
||||
var addRankings = WebService.GetRecordFileFromServer(randomUser.Select(n => n.RankingId).ToList());
|
||||
mapRecordRankings.AddRange(addRankings);
|
||||
}
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user