hch
35 分钟以前 cba555476b1f1b856b9211451e739d8cdce0eeba
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
using LitJson;
 
public class ServerListParser : SingletonMonobehaviour<ServerListParser>
{
 
    bool hasCommonResult = false;
    ServerInfoCommon serverInfoCommon;
    bool hasPlayerResult = false;
    ServerInfoPlayer serverInfoPlayer;
 
    public void PushCommonServerListRawData(string content)
    {
        hasCommonResult = false;
        ThreadPool.QueueUserWorkItem((object aaa) =>
        {
            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)
            return;
 
        ThreadPool.QueueUserWorkItem((object aaa) =>
        {
            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;
        }
    }
 
}