1616 包括网络创建、持久化协议、entities的管理、以及引起对外可调用接口。
1717
1818 一些可以参考的地方:
19- http://www. kbengine.org /docs/programming/clientsdkprogramming.html
20- http://www. kbengine.org /docs/programming/kbe_message_format.html
19+ http://kbengine.github.io /docs/programming/clientsdkprogramming.html
20+ http://kbengine.github.io /docs/programming/kbe_message_format.html
2121
22- http://www. kbengine.org /cn/docs/programming/clientsdkprogramming.html
23- http://www. kbengine.org /cn/docs/programming/kbe_message_format.html
22+ http://kbengine.github.io /cn/docs/programming/clientsdkprogramming.html
23+ http://kbengine.github.io /cn/docs/programming/kbe_message_format.html
2424 */
2525 public class KBEngineApp
2626 {
@@ -30,8 +30,8 @@ public class KBEngineApp
3030 KBEngineArgs _args = null ;
3131
3232 // 客户端的类别
33- // http://www. kbengine.org /docs/programming/clientsdkprogramming.html
34- // http://www. kbengine.org /cn/docs/programming/clientsdkprogramming.html
33+ // http://kbengine.github.io /docs/programming/clientsdkprogramming.html
34+ // http://kbengine.github.io /cn/docs/programming/clientsdkprogramming.html
3535 public enum CLIENT_TYPE
3636 {
3737 // Mobile(Phone, Pad)
@@ -77,7 +77,7 @@ public enum CLIENT_TYPE
7777
7878 // 服务端与客户端的版本号以及协议MD5
7979 public string serverVersion = "" ;
80- public string clientVersion = "1.1.9 " ;
80+ public string clientVersion = "1.1.10 " ;
8181 public string serverScriptVersion = "" ;
8282 public string clientScriptVersion = "0.1.0" ;
8383 public string serverProtocolMD5 = "4930E6C01028CE4D5B3CE228CA841378" ;
@@ -112,6 +112,10 @@ public enum CLIENT_TYPE
112112 private System . DateTime _lastTickCBTime = System . DateTime . Now ;
113113 private System . DateTime _lastUpdateToServerTime = System . DateTime . Now ;
114114
115+ //上传玩家信息到服务器间隔,单位毫秒
116+ private float _updatePlayerToServerPeroid = 100.0f ;
117+ private const int _1MS_TO_100NS = 10000 ;
118+
115119 // 玩家当前所在空间的id, 以及空间对应的资源
116120 public UInt32 spaceID = 0 ;
117121 public string spaceResPath = "" ;
@@ -133,7 +137,8 @@ public KBEngineApp(KBEngineArgs args)
133137 public virtual bool initialize ( KBEngineArgs args )
134138 {
135139 _args = args ;
136-
140+ _updatePlayerToServerPeroid = ( float ) _args . syncPlayerMS ;
141+
137142 EntityDef . init ( ) ;
138143
139144 initNetwork ( ) ;
@@ -551,7 +556,10 @@ private void onLogin_baseapp()
551556 一些移动类应用容易掉线,可以使用该功能快速的重新与服务端建立通信
552557 */
553558 public void reloginBaseapp ( )
554- {
559+ {
560+ _lastTickTime = System . DateTime . Now ;
561+ _lastTickCBTime = System . DateTime . Now ;
562+
555563 if ( _networkInterface . valid ( ) )
556564 return ;
557565
@@ -1274,26 +1282,26 @@ public void Client_onControlEntity(Int32 eid, sbyte isControlled)
12741282 }
12751283
12761284 /*
1277- 更新当前玩家的位置与朝向到服务端, 可以通过开关_syncPlayer关闭这个机制
1285+ 更新当前玩家的位置与朝向到服务端, 可以通过开关_syncPlayerMS关闭这个机制
12781286 */
12791287 public void updatePlayerToServer ( )
12801288 {
1281- if ( ! _args . syncPlayer || spaceID == 0 )
1289+ if ( _updatePlayerToServerPeroid <= 0.01f || spaceID == 0 )
12821290 {
12831291 return ;
12841292 }
12851293
12861294 var now = DateTime . Now ;
12871295 TimeSpan span = now - _lastUpdateToServerTime ;
12881296
1289- if ( span . Ticks < 1000000 )
1290- return ;
1297+ if ( span . Ticks < _updatePlayerToServerPeroid * _1MS_TO_100NS )
1298+ return ;
12911299
12921300 Entity playerEntity = player ( ) ;
12931301 if ( playerEntity == null || playerEntity . inWorld == false || playerEntity . isControlled )
12941302 return ;
12951303
1296- _lastUpdateToServerTime = now - ( span - TimeSpan . FromTicks ( 1000000 ) ) ;
1304+ _lastUpdateToServerTime = now - ( span - TimeSpan . FromTicks ( Convert . ToInt64 ( _updatePlayerToServerPeroid * _1MS_TO_100NS ) ) ) ;
12971305
12981306 Vector3 position = playerEntity . position ;
12991307 Vector3 direction = playerEntity . direction ;
0 commit comments