Skip to content

Commit ff99588

Browse files
committed
用户层可能也需要一个版本号支持
kbengine#123
1 parent c72a1aa commit ff99588

24 files changed

+207
-68
lines changed

kbe/res/server/kbengine_defs.xml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,19 @@
7777
-->
7878
<debugEntity>0</debugEntity>
7979

80-
<!-- apps发布状态, 可在脚本中获取该值
81-
(apps released state, This value can be obtained in the script)
82-
Type: Integer8
83-
0 : debug
84-
1 : release
85-
其他自定义(Other custom)
86-
-->
87-
<app_publish>0</app_publish>
80+
<publish>
81+
<!-- 发布状态, 可在脚本中获取该值。 KBEngine.publish()
82+
(apps released state, This value can be obtained in the script. KBEngine.publish())
83+
Type: Integer8
84+
0 : debug
85+
1 : release
86+
其他自定义(Other custom)
87+
-->
88+
<state>0</state>
89+
90+
<!-- 脚本层发布版本 -->
91+
<script_version> 0.1.0 </script_version>
92+
</publish>
8893

8994
<channelCommon>
9095
<!-- 最后一次通信时间超过此时间则被认定为超时通道, 服务器将踢出该通道
@@ -150,7 +155,7 @@
150155
<!-- 关服倒计时(秒)
151156
(Countdown to shutdown the server(seconds))
152157
-->
153-
<shutdown_time> 60.0 </shutdown_time>
158+
<shutdown_time> 1.0 </shutdown_time>
154159

155160
<!-- 关闭服务器的时候, 如果有未完成的任务, 服务器需要等待任务结束。
156161
每Tick(秒)检查一次
@@ -374,10 +379,10 @@
374379
(if is true, Engine start is completed, start to record profile information,
375380
Process exit will export a report.)
376381
-->
377-
<cprofile> false </cprofile>
378-
<pyprofile> false </pyprofile>
379-
<eventprofile> false </eventprofile>
380-
<mercuryprofile> false </mercuryprofile>
382+
<cprofile> true </cprofile>
383+
<pyprofile> true </pyprofile>
384+
<eventprofile> true </eventprofile>
385+
<mercuryprofile> true </mercuryprofile>
381386
</profiles>
382387

383388
<ghostDistance> 500.0 </ghostDistance>
@@ -524,10 +529,10 @@
524529
(if is true, Engine start is completed, start to record profile information,
525530
Process exit will export a report.)
526531
-->
527-
<cprofile> false </cprofile>
528-
<pyprofile> false </pyprofile>
529-
<eventprofile> false </eventprofile>
530-
<mercuryprofile> false </mercuryprofile>
532+
<cprofile> true </cprofile>
533+
<pyprofile> true </pyprofile>
534+
<eventprofile> true </eventprofile>
535+
<mercuryprofile> true </mercuryprofile>
531536
</profiles>
532537

533538
<!-- listen监听队列最大值

kbe/src/lib/client_lib/client_interface.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ NETWORK_INTERFACE_DECLARE_BEGIN(ClientInterface)
5555
// 和服务端的版本不匹配
5656
CLIENT_MESSAGE_DECLARE_STREAM(onVersionNotMatch, MERCURY_VARIABLE_MESSAGE)
5757

58+
// 和服务端的脚本层版本不匹配
59+
CLIENT_MESSAGE_DECLARE_STREAM(onScriptVersionNotMatch, MERCURY_VARIABLE_MESSAGE)
60+
5861
// 创建账号失败。
5962
CLIENT_MESSAGE_DECLARE_STREAM(onCreateAccountResult, MERCURY_VARIABLE_MESSAGE)
6063

kbe/src/lib/client_lib/clientapp.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ void ClientApp::handleGameTick()
373373
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
374374
(*pBundle).newMessage(BaseappInterface::hello);
375375
(*pBundle) << KBEVersion::versionString();
376-
376+
(*pBundle) << KBEVersion::scriptVersionString();
377+
377378
if(Mercury::g_channelExternalEncryptType == 1)
378379
{
379380
pBlowfishFilter_ = new Mercury::BlowfishFilter();
@@ -586,6 +587,7 @@ bool ClientApp::login(std::string accountName, std::string passwd,
586587
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
587588
(*pBundle).newMessage(LoginappInterface::hello);
588589
(*pBundle) << KBEVersion::versionString();
590+
(*pBundle) << KBEVersion::scriptVersionString();
589591

590592
if(Mercury::g_channelExternalEncryptType == 1)
591593
{
@@ -607,7 +609,7 @@ bool ClientApp::login(std::string accountName, std::string passwd,
607609

608610
//-------------------------------------------------------------------------------------
609611
void ClientApp::onHelloCB_(Mercury::Channel* pChannel, const std::string& verInfo,
610-
COMPONENT_TYPE componentType)
612+
const std::string& scriptVerInfo, COMPONENT_TYPE componentType)
611613
{
612614
if(Mercury::g_channelExternalEncryptType == 1)
613615
{
@@ -631,6 +633,12 @@ void ClientApp::onVersionNotMatch(Mercury::Channel * pChannel, MemoryStream& s)
631633
ClientObjectBase::onVersionNotMatch(pChannel, s);
632634
}
633635

636+
//-------------------------------------------------------------------------------------
637+
void ClientApp::onScriptVersionNotMatch(Mercury::Channel * pChannel, MemoryStream& s)
638+
{
639+
ClientObjectBase::onScriptVersionNotMatch(pChannel, s);
640+
}
641+
634642
//-------------------------------------------------------------------------------------
635643
void ClientApp::onLoginSuccessfully(Mercury::Channel * pChannel, MemoryStream& s)
636644
{

kbe/src/lib/client_lib/clientapp.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,18 @@ class ClientApp :
136136
virtual void onChannelDeregister(Mercury::Channel * pChannel);
137137

138138
virtual void onHelloCB_(Mercury::Channel* pChannel, const std::string& verInfo,
139-
COMPONENT_TYPE componentType);
139+
const std::string& scriptVerInfo, COMPONENT_TYPE componentType);
140140

141141
/** 网络接口
142142
和服务端的版本不匹配
143143
*/
144144
virtual void onVersionNotMatch(Mercury::Channel* pChannel, MemoryStream& s);
145145

146+
/** 网络接口
147+
和服务端的脚本层版本不匹配
148+
*/
149+
virtual void onScriptVersionNotMatch(Mercury::Channel* pChannel, MemoryStream& s);
150+
146151
/** 网络接口
147152
登录成功
148153
@ip: 服务器ip地址

kbe/src/lib/client_lib/clientobjectbase.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ void ClientObjectBase::fireEvent(const EventData* pEventData)
505505

506506
//-------------------------------------------------------------------------------------
507507
void ClientObjectBase::onHelloCB_(Mercury::Channel* pChannel, const std::string& verInfo,
508-
COMPONENT_TYPE componentType)
508+
const std::string& scriptVerInfo, COMPONENT_TYPE componentType)
509509
{
510510
}
511511

@@ -515,13 +515,16 @@ void ClientObjectBase::onHelloCB(Mercury::Channel* pChannel, MemoryStream& s)
515515
std::string verInfo;
516516
s >> verInfo;
517517

518+
std::string scriptVerInfo;
519+
s >> scriptVerInfo;
520+
518521
COMPONENT_TYPE ctype;
519522
s >> ctype;
520523

521-
INFO_MSG(boost::format("ClientObjectBase::onHelloCB: verInfo=%1%, addr:%2%\n") %
522-
verInfo % pChannel->c_str());
524+
INFO_MSG(boost::format("ClientObjectBase::onHelloCB: verInfo=%1%, scriptVerInfo=%2%, addr:%3%\n") %
525+
verInfo % scriptVerInfo % pChannel->c_str());
523526

524-
onHelloCB_(pChannel, verInfo, ctype);
527+
onHelloCB_(pChannel, verInfo, scriptVerInfo, ctype);
525528
}
526529

527530
//-------------------------------------------------------------------------------------
@@ -539,6 +542,21 @@ void ClientObjectBase::onVersionNotMatch(Mercury::Channel* pChannel, MemoryStrea
539542
eventHandler_.fire(&eventdata);
540543
}
541544

545+
//-------------------------------------------------------------------------------------
546+
void ClientObjectBase::onScriptVersionNotMatch(Mercury::Channel* pChannel, MemoryStream& s)
547+
{
548+
std::string verInfo;
549+
s >> verInfo;
550+
551+
INFO_MSG(boost::format("ClientObjectBase::onScriptVersionNotMatch: verInfo=%1% not match(server:%2%)\n") %
552+
KBEVersion::scriptVersionString() % verInfo);
553+
554+
EventData_ScriptVersionNotMatch eventdata;
555+
eventdata.verInfo = KBEVersion::scriptVersionString();
556+
eventdata.serVerInfo = verInfo;
557+
eventHandler_.fire(&eventdata);
558+
}
559+
542560
//-------------------------------------------------------------------------------------
543561
bool ClientObjectBase::login()
544562
{

kbe/src/lib/client_lib/clientobjectbase.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ class ClientObjectBase : public script::ScriptObject
141141
/** 网络接口
142142
客户端与服务端第一次建立交互, 服务端返回
143143
*/
144-
virtual void onHelloCB_(Mercury::Channel* pChannel, const std::string& verInfo,
145-
COMPONENT_TYPE componentType);
144+
virtual void onHelloCB_(Mercury::Channel* pChannel, const std::string& verInfo,
145+
const std::string& scriptVerInfo, COMPONENT_TYPE componentType);
146146

147147
virtual void onHelloCB(Mercury::Channel* pChannel, MemoryStream& s);
148148

@@ -151,6 +151,10 @@ class ClientObjectBase : public script::ScriptObject
151151
*/
152152
virtual void onVersionNotMatch(Mercury::Channel* pChannel, MemoryStream& s);
153153

154+
/** 网络接口
155+
和服务端的脚本层版本不匹配
156+
*/
157+
virtual void onScriptVersionNotMatch(Mercury::Channel* pChannel, MemoryStream& s);
154158

155159
/** 网络接口
156160
创建账号成功和失败回调

kbe/src/lib/client_lib/event.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ typedef int32 EventID;
5050
#define CLIENT_EVENT_VERSION_NOT_MATCH 18
5151
#define CLIENT_EVENT_ON_KICKED 19
5252
#define CLIENT_EVENT_LAST_ACCOUNT_INFO 20
53+
#define CLIENT_EVENT_SCRIPT_VERSION_NOT_MATCH 21
5354

5455
struct EventData
5556
{
@@ -334,6 +335,17 @@ struct EventData_VersionNotMatch : public EventData
334335
std::string serVerInfo;
335336
};
336337

338+
struct EventData_ScriptVersionNotMatch : public EventData
339+
{
340+
EventData_ScriptVersionNotMatch():
341+
EventData(CLIENT_EVENT_SCRIPT_VERSION_NOT_MATCH)
342+
{
343+
}
344+
345+
std::string verInfo;
346+
std::string serVerInfo;
347+
};
348+
337349
struct EventData_onKicked : public EventData
338350
{
339351
EventData_onKicked():
@@ -403,6 +415,9 @@ inline EventData* newKBEngineEvent(EventID v)
403415
case CLIENT_EVENT_VERSION_NOT_MATCH:
404416
return new EventData_VersionNotMatch();
405417
break;
418+
case CLIENT_EVENT_SCRIPT_VERSION_NOT_MATCH:
419+
return new EventData_ScriptVersionNotMatch();
420+
break;
406421
case CLIENT_EVENT_ON_KICKED:
407422
return new EventData_onKicked();
408423
break;
@@ -494,6 +509,10 @@ inline EventData* copyKBEngineEvent(const KBEngine::EventData* lpEventData)
494509
peventdata = new EventData_VersionNotMatch();
495510
(*static_cast<EventData_VersionNotMatch*>(peventdata)) = (*static_cast<const EventData_VersionNotMatch*>(lpEventData));
496511
break;
512+
case CLIENT_EVENT_SCRIPT_VERSION_NOT_MATCH:
513+
peventdata = new EventData_ScriptVersionNotMatch();
514+
(*static_cast<EventData_ScriptVersionNotMatch*>(peventdata)) = (*static_cast<const EventData_ScriptVersionNotMatch*>(lpEventData));
515+
break;
497516
case CLIENT_EVENT_ON_KICKED:
498517
peventdata = new EventData_onKicked();
499518
(*static_cast<EventData_onKicked*>(peventdata)) = (*static_cast<const EventData_onKicked*>(lpEventData));

kbe/src/lib/client_lib/kbemain.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ inline void START_MSG(const char * name, uint64 appuid)
3939

4040
std::string s = (boost::format("---- %1% "
4141
"Version: %2%. "
42-
"Config: %3%. "
43-
"Built: %4% %5%. "
44-
"AppUID: %6%. "
45-
"UID: %7%. "
46-
"PID: %8% ----\n") %
47-
name % KBEVersion::versionString().c_str() %
42+
"ScriptVersion: %3%. "
43+
"Config: %4%. "
44+
"Built: %5% %6%. "
45+
"AppUID: %7%. "
46+
"UID: %8%. "
47+
"PID: %9% ----\n") %
48+
name % KBEVersion::versionString() % KBEVersion::scriptVersionString() %
4849
KBE_CONFIG % __TIME__ % __DATE__ %
4950
appuid % getUserUID() % getProcessPID()).str();
5051

kbe/src/lib/cstdkbe/kbeversion.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ namespace KBEVersion
2525
{
2626
std::string g_versionString;
2727

28+
/**
29+
½Å±¾²ã°æ±¾
30+
*/
31+
std::string g_scriptVersion = "0.0.0";
2832

2933
const std::string & versionString()
3034
{
@@ -38,7 +42,15 @@ const std::string & versionString()
3842
return g_versionString;
3943
}
4044

45+
void setScriptVersion(const std::string& ver)
46+
{
47+
g_scriptVersion = ver;
48+
}
4149

50+
const std::string & scriptVersionString()
51+
{
52+
return g_scriptVersion;
53+
}
4254

4355

4456
}

kbe/src/lib/cstdkbe/kbeversion.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,24 @@ You should have received a copy of the GNU Lesser General Public License
1818
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21+
#ifndef KBEVERSION_HPP
22+
#define KBEVERSION_HPP
23+
2124
#include "cstdkbe/platform.hpp"
22-
#ifndef __KBEVERSION_HPP__
23-
#define __KBEVERSION_HPP__
25+
2426
namespace KBEngine{
2527

2628
#define KBE_VERSION_MAJOR 0
2729
#define KBE_VERSION_MINOR 1
28-
#define KBE_VERSION_PATCH 12
30+
#define KBE_VERSION_PATCH 13
31+
2932

3033
namespace KBEVersion
3134
{
3235
const std::string & versionString();
36+
void setScriptVersion(const std::string& ver);
37+
const std::string & scriptVersionString();
3338
}
3439

3540
}
36-
#endif // __KBEVERSION_HPP__
41+
#endif // KBEVERSION_HPP

kbe/src/lib/server/kbemain.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ inline void START_MSG(const char * name, uint64 appuid)
4545

4646
std::string s = (boost::format("---- %1% "
4747
"Version: %2%. "
48-
"Config: %3%. "
49-
"Built: %4% %5%. "
50-
"AppUID: %6%. "
51-
"UID: %7%. "
52-
"PID: %8% ----\n") %
53-
name % KBEVersion::versionString().c_str() %
48+
"ScriptVersion: %3%. "
49+
"Config: %4%. "
50+
"Built: %5% %6%. "
51+
"AppUID: %7%. "
52+
"UID: %8%. "
53+
"PID: %9% ----\n") %
54+
name % KBEVersion::versionString() % KBEVersion::scriptVersionString() %
5455
KBE_CONFIG % __TIME__ % __DATE__ %
5556
appuid % getUserUID() % getProcessPID()).str();
5657

kbe/src/lib/server/pendingLoginmgr.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ bool PendingLoginMgr::add(PLInfos* infos)
7777
pPLMap_[infos->accountName] = infos;
7878
infos->lastProcessTime = timestamp();
7979

80-
if(pPLMap_.size() > 64)
81-
{
82-
DEBUG_MSG(boost::format("PendingLoginMgr::add: size=%1%.\n") % pPLMap_.size());
83-
}
8480

81+
DEBUG_MSG(boost::format("PendingLoginMgr::add: %1%, size=%2%.\n") % infos->accountName % pPLMap_.size());
8582
return true;
8683
}
8784

@@ -93,6 +90,7 @@ PendingLoginMgr::PLInfos* PendingLoginMgr::remove(std::string& accountName)
9390
{
9491
PLInfos* infos = iter->second;
9592
pPLMap_.erase(iter);
93+
DEBUG_MSG(boost::format("PendingLoginMgr::remove: %1%, size=%2%.\n") % accountName % pPLMap_.size());
9694
return infos;
9795
}
9896

0 commit comments

Comments
 (0)