Skip to content

Commit

Permalink
sendTick频率可配
Browse files Browse the repository at this point in the history
  • Loading branch information
kebiao committed Jan 15, 2018
1 parent 9c25f02 commit a1bb903
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions KBEMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class KBEMain : MonoBehaviour
public string persistentDataPath = "Application.persistentDataPath";
public bool syncPlayer = true;
public int threadUpdateHZ = 10;
public int serverHeartbeatTick = 15;
public int SEND_BUFFER_MAX = (int)KBEngine.NetworkInterface.TCP_PACKET_MAX;
public int RECV_BUFFER_MAX = (int)KBEngine.NetworkInterface.TCP_PACKET_MAX;
public bool useAliasEntityID = true;
Expand Down Expand Up @@ -62,6 +63,7 @@ public virtual void initKBEngine()

args.syncPlayer = syncPlayer;
args.threadUpdateHZ = threadUpdateHZ;
args.serverHeartbeatTick = serverHeartbeatTick;
args.useAliasEntityID = useAliasEntityID;
args.isOnInitCallPropertysSetMethods = isOnInitCallPropertysSetMethods;

Expand Down
2 changes: 1 addition & 1 deletion KBEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public void sendTick()
// 更新玩家的位置与朝向到服务端
updatePlayerToServer();

if(span.Seconds > 15)
if(span.Seconds > _args.serverHeartbeatTick)
{
span = _lastTickCBTime - _lastTickTime;

Expand Down
3 changes: 3 additions & 0 deletions KBEngineArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class KBEngineArgs
// 线程主循环处理频率
public int threadUpdateHZ = 10;

// 心跳频率(tick数)
public int serverHeartbeatTick = 15;

public int getRecvBufferSize()
{
return (int)RECV_BUFFER_MAX;
Expand Down

0 comments on commit a1bb903

Please sign in to comment.