yyl
2026-05-11 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using UnityEngine;
using LitJson;
 
public class ServerListParser : SingletonMonobehaviour<ServerListParser>
{
 
    bool hasCommonResult = false;
    ServerInfoCommon serverInfoCommon;
    bool hasPlayerResult = false;
    ServerInfoPlayer serverInfoPlayer;
 
    public void PushCommonServerListRawData(string content)
    {
        hasCommonResult = false;
        ParseCommonServerListAsync(content).Forget();
    }
 
    private async UniTaskVoid ParseCommonServerListAsync(string content)
    {
        await UniTask.Yield();
        serverInfoCommon = JsonMapper.ToObject<ServerInfoCommon>(content);
        hasCommonResult = true;
    }
 
    public void PushPlayerServerListRawData(string content)
    {
        hasPlayerResult = false;
        Debug.Log("ServerListParser:" + content);
        if (content == "" || content == "{}")
            return;
        JsonData RankArr = JsonMapper.ToObject(content);
        if (RankArr["player"]["group_list"].Count == 0)
        {
            if (!RankArr.ContainsKey("gametest"))
            {
                return;
            }
        }
 
        ParsePlayerServerListAsync(content).Forget();
    }
 
    private async UniTaskVoid ParsePlayerServerListAsync(string content)
    {
        await UniTask.Yield();
        serverInfoPlayer = JsonMapper.ToObject<ServerInfoPlayer>(content);
        hasPlayerResult = true;
        SetIsInWhiteList();
    }
 
    public void ReportCommonResult()
    {
        if (serverInfoCommon != null)
        {
            ServerListCenter.Instance.SetServerlistCommon(serverInfoCommon);
        }
    }
 
    public void ReportPlayerResult()
    {
        if (serverInfoPlayer != null)
        {
            ServerListCenter.Instance.SetServerListPlayer(serverInfoPlayer);
        }
    }
 
    public void SetIsInWhiteList()
    {
        DebugUtility.Instance.isWhiteListAccount = serverInfoPlayer.white == 1;
    }
 
 
    private void Update()
    {
        if (hasCommonResult)
        {
            ReportCommonResult();
            hasCommonResult = false;
        }
 
        if (hasPlayerResult)
        {
            ReportPlayerResult();
            hasPlayerResult = false;
        }
    }
 
}