少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
102
103
104
105
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
 
public class StageLoadTimeOutCatcher : MonoBehaviour
{
    public static ProtocolRecorder got0102Time;
    public static ProtocolRecorder gotA126Time;
    public static ProtocolRecorder gotA127Time;
    public static ProtocolRecorder got0109Time;
    public static ProtocolRecorder got0403Time;
    public static ProtocolRecorder send0107Time;
 
    static StageLoadTimeOutCatcher timeOutCatcher;
 
    public int stageId = 0;
    public DateTime startTime;
 
    private void Awake()
    {
        startTime = DateTime.Now;
    }
 
    public static void Begin(int stageId)
    {
        if (timeOutCatcher != null)
        {
            DestroyImmediate(timeOutCatcher.gameObject);
            timeOutCatcher = null;
        }
 
        var go = new GameObject("StageLoadTimeOutCatcher");
        var catcher = go.AddMissingComponent<StageLoadTimeOutCatcher>();
        catcher.stageId = stageId;
        timeOutCatcher = catcher;
        DontDestroyOnLoad(go);
    }
 
    public static void Stop()
    {
        if (timeOutCatcher != null)
        {
            DestroyImmediate(timeOutCatcher.gameObject);
            timeOutCatcher = null;
        }
    }
 
    public static void ReportLoadingOverTime()
    {
        if (timeOutCatcher != null)
        {
            DestroyImmediate(timeOutCatcher.gameObject);
            timeOutCatcher = null;
        }
    }
 
    public static void RecordProtocol(ServerType socketType, string number, DateTime time)
    {
        var recorder = new ProtocolRecorder(number, time, socketType);
        switch (number)
        {
            case "0102":
                got0102Time = recorder;
                break;
            case "A126":
                gotA126Time = recorder;
                break;
            case "A127":
                gotA127Time = recorder;
                break;
            case "0109":
                got0109Time = recorder;
                break;
            case "0107":
                send0107Time = recorder;
                break;
            case "0403":
                got0403Time = recorder;
                break;
            default:
                break;
        }
    }
 
    public struct ProtocolRecorder
    {
        public string number;
        public DateTime time;
        public ServerType socketType;
 
        public ProtocolRecorder(string number, DateTime time, ServerType socketType)
        {
            this.number = number;
            this.time = time;
            this.socketType = socketType;
        }
 
        public override string ToString()
        {
            return StringUtility.Contact("封包:", number, ";", "时间:", time.ToString("HH:mm:ss"), ";", "服务器:", socketType);
        }
    }
 
}