少年修仙传客户端代码仓库
client_Hale
2019-04-13 d4b5806a57e4e88a1fc57dd95f17e185f33e4e43
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
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;
        ThreadPool.QueueUserWorkItem((object aaa) =>
        {
            serverInfoPlayer = JsonMapper.ToObject<ServerInfoPlayer>(content);
            hasPlayerResult = true;
        });
    }
 
    public void ReportCommonResult()
    {
        if (serverInfoCommon != null)
        {
            ServerListCenter.Instance.SetServerlistCommon(serverInfoCommon);
        }
    }
 
    public void ReportPlayerResult()
    {
        if (serverInfoPlayer != null)
        {
            ServerListCenter.Instance.SetServerListPlayer(serverInfoPlayer);
        }
    }
 
    private void Update()
    {
        if (hasCommonResult)
        {
            ReportCommonResult();
            hasCommonResult = false;
        }
 
        if (hasPlayerResult)
        {
            ReportPlayerResult();
            hasPlayerResult = false;
        }
    }
 
}