少年修仙传客户端代码仓库
client_Wu Xijin
2018-08-14 99a3f198578f79b48bca1821554fb4b76270cd27
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
92
93
94
95
96
97
98
99
100
101
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Text;
 
public class NetPkgCtl
{
    private static List<NetPkg> _typeLst = null; //发送接收封包存储列表
    private static List<NetPkg> _tempNetPkgLst = null;//暂停时缓存的封包列表
    public static bool IsStopRec = false;
    public static bool getNewPackage = false;
 
    /// <summary>
    /// 添加封包到封包查看工具
    /// </summary>
    /// <param name="gameNetPkg"></param>
    /// <param name="typeLst"></param>
    public static void AddNetPkg(string pkgByte, NetPkgType netPkgType, string _packName, string _fields, List<string> _fieldDetails)
    {
#if UNITY_EDITOR
        if (_typeLst == null)
        {
            _typeLst = new List<NetPkg>();
        }
        if (_tempNetPkgLst == null)
        {
            _tempNetPkgLst = new List<NetPkg>();
        }
 
        getNewPackage = true;
 
        NetPkg netPkg = new NetPkg();
        netPkg.SendOrGetTime = DateTime.Now.ToString("HH:mm:ss:fff");
        netPkg.NetPkgTp = netPkgType;
 
        string netPkgStr = pkgByte.Replace(",", " ");
        netPkg.GameNetPkgStr = netPkgStr;
 
        var gameNetPkgName = _packName;
        string[] byteStr = netPkgStr.Split(' ');
        if (string.IsNullOrEmpty(gameNetPkgName))
        {
            if (byteStr.Length > 1)
            {
                StringBuilder _stringBuilder = new StringBuilder();
                _stringBuilder.Append("H");
                _stringBuilder.Append(byteStr[0]);
                _stringBuilder.Append(byteStr[1]);
                _stringBuilder.Append("(未注册)");
                netPkg.GameNetName = _stringBuilder.ToString();
                _stringBuilder = null;
            }
        }
        else
        {
            netPkg.GameNetName = gameNetPkgName;
            netPkg.fields = _fields;
            netPkg.fieldDetails = _fieldDetails;
        }
 
        if (!IsStopRec)
        {
            _typeLst.Add(netPkg);
        }
        else
        {
            _tempNetPkgLst.Add(netPkg);
        }
#endif
    }
 
    public static List<NetPkg> GetNetPkg()
    {
        return _typeLst;
    }
 
    public static List<NetPkg> GetTempNetPkg()
    {
        return _tempNetPkgLst;
    }
}
 
public class NetPkg
{
    public string SendOrGetTime;
    public string GameNetPkgStr;
    public string GameNetName;
    public NetPkgType NetPkgTp;
    public string fields;
    public List<string> fieldDetails;
 
}
 
public enum NetPkgType
{
    Client = 1,
    Server = 2,
    All = 3,
}