blob: ddb5f5e4e8b3cc2e4dbfd8008f5a26e0b5b3e3b5 (
plain)
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
|
using System;
using XUtliPoolLib;
namespace XMainClient
{
internal class XServerTimeMgr : XSingleton<XServerTimeMgr>
{
public static readonly long SyncTimeOut = 2000L;
private long _TimeDelay = 0L;
private uint _token = 0u;
private PtcC2G_DelayNotify _delay = new PtcC2G_DelayNotify();
private XTimerMgr.ElapsedEventHandler _onTimerStartSyncTime = null;
private RpcC2G_SyncTime syncTimeRpc = new RpcC2G_SyncTime();
public XServerTimeMgr()
{
this._onTimerStartSyncTime = new XTimerMgr.ElapsedEventHandler(this.OnStartSyncTime);
}
public override bool Init()
{
this.OnStartSyncTime(null);
return true;
}
public override void Uninit()
{
XSingleton<XTimerMgr>.singleton.KillTimer(this._token);
}
public long GetDelay()
{
return this._TimeDelay;
}
private void OnStartSyncTime(object param)
{
bool flag = XSingleton<XClientNetwork>.singleton.XLoginStep == XLoginStep.Playing;
if (flag)
{
this.syncTimeRpc.oArg.time = DateTime.Now.Ticks;
XSingleton<XClientNetwork>.singleton.Send(this.syncTimeRpc);
}
else
{
this.Trigger();
}
}
public void OnSyncTime(long sendAt, long replayAt)
{
double num = (double)(replayAt - sendAt) / 10000.0;
this._TimeDelay = (long)num;
this._delay.Data.delay = (uint)this._TimeDelay;
XSingleton<XClientNetwork>.singleton.Send(this._delay);
this.Trigger();
}
public void OnSyncTimeout()
{
XSingleton<XDebug>.singleton.AddLog("Ping time out!", null, null, null, null, null, XDebugColor.XDebug_None);
bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.World && XSingleton<XClientNetwork>.singleton.IsConnected() && !XSingleton<XClientNetwork>.singleton.XConnect.OnReconnect && !Rpc.OnRpcDelay;
if (flag)
{
}
this._TimeDelay = XServerTimeMgr.SyncTimeOut;
this.Trigger();
}
private void Trigger()
{
XSingleton<XTimerMgr>.singleton.KillTimer(this._token);
this._token = XSingleton<XTimerMgr>.singleton.SetGlobalTimer((float)XSingleton<XGlobalConfig>.singleton.PINGInterval, this._onTimerStartSyncTime, null);
}
}
}
|