心跳包处理
This commit is contained in:
parent
16ec2247d8
commit
3159ada61c
@ -94,7 +94,7 @@ namespace GameLogic
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float timerDt = 2;
|
||||
public void OnUpdate()
|
||||
{
|
||||
if (m_WebSocket != null && m_WebSocket.ReadyState == WebSocketState.Open)
|
||||
@ -117,8 +117,26 @@ namespace GameLogic
|
||||
item.Value.Clear();
|
||||
}
|
||||
|
||||
timerDt -= Time.deltaTime;
|
||||
if (timerDt <= 0)
|
||||
{
|
||||
// 执行一次Ack
|
||||
timerDt = 2;
|
||||
OnHbTimer();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 心跳包
|
||||
/// </summary>
|
||||
private void OnHbTimer()
|
||||
{
|
||||
// 心跳包
|
||||
Dictionary<string, string> dis = new Dictionary<string, string>();
|
||||
dis.Add("type", "hb");
|
||||
m_WebSocket.SendAsync(dis.ToJson());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试服流程初始化
|
||||
|
Loading…
x
Reference in New Issue
Block a user