Skip to content

Commit b5840f6

Browse files
committed
fix(Network): 修正应用获得焦点时心跳包的默认行为
将m_FocusHeartbeat默认值从true改为false,并添加条件判断确保仅在启用时发送心跳包
1 parent c07dee1 commit b5840f6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Runtime/Network/NetworkComponent.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public sealed class NetworkComponent : GameFrameworkComponent
6363
[SerializeField] private int m_rpcTimeout = 5000;
6464

6565
/// <summary>
66-
/// 是否在应用程序获得焦点时发送心跳包,默认为true
66+
/// 是否在应用程序获得焦点时发送心跳包,默认为false
6767
/// </summary>
68-
[SerializeField] private bool m_FocusHeartbeat = true;
68+
[SerializeField] private bool m_FocusHeartbeat = false;
6969

7070
/// <summary>
7171
/// 获取网络频道数量。
@@ -87,6 +87,11 @@ public int NetworkChannelCount
8787
private void OnApplicationFocus(bool hasFocus)
8888
{
8989
_isGaming = hasFocus;
90+
if (!m_FocusHeartbeat)
91+
{
92+
return;
93+
}
94+
9095
m_NetworkManager.SetFocusHeartbeat(hasFocus);
9196
Log.Info($"SetFocusHeartbeat: {hasFocus}");
9297
}

0 commit comments

Comments
 (0)