Skip to content

Commit a1bb903

Browse files
committed
sendTick频率可配
kbengine/kbengine#544
1 parent 9c25f02 commit a1bb903

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

KBEMain.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class KBEMain : MonoBehaviour
2121
public string persistentDataPath = "Application.persistentDataPath";
2222
public bool syncPlayer = true;
2323
public int threadUpdateHZ = 10;
24+
public int serverHeartbeatTick = 15;
2425
public int SEND_BUFFER_MAX = (int)KBEngine.NetworkInterface.TCP_PACKET_MAX;
2526
public int RECV_BUFFER_MAX = (int)KBEngine.NetworkInterface.TCP_PACKET_MAX;
2627
public bool useAliasEntityID = true;
@@ -62,6 +63,7 @@ public virtual void initKBEngine()
6263

6364
args.syncPlayer = syncPlayer;
6465
args.threadUpdateHZ = threadUpdateHZ;
66+
args.serverHeartbeatTick = serverHeartbeatTick;
6567
args.useAliasEntityID = useAliasEntityID;
6668
args.isOnInitCallPropertysSetMethods = isOnInitCallPropertysSetMethods;
6769

KBEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public void sendTick()
324324
// 更新玩家的位置与朝向到服务端
325325
updatePlayerToServer();
326326

327-
if(span.Seconds > 15)
327+
if(span.Seconds > _args.serverHeartbeatTick)
328328
{
329329
span = _lastTickCBTime - _lastTickTime;
330330

KBEngineArgs.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public class KBEngineArgs
4646
// 线程主循环处理频率
4747
public int threadUpdateHZ = 10;
4848

49+
// 心跳频率(tick数)
50+
public int serverHeartbeatTick = 15;
51+
4952
public int getRecvBufferSize()
5053
{
5154
return (int)RECV_BUFFER_MAX;

0 commit comments

Comments
 (0)