Skip to content

Commit aefbd10

Browse files
author
kbengine
committed
globalBases改名为baseAppData和cellapp上的cellAppData对应。
kbengine只提供3种数据共享机制: 1: baseapps共享 (baseAppData) 2:cellapps共享 (cellAppData) 3:baseapps + cellapps 共享 (globalData)
1 parent 1b76bc4 commit aefbd10

14 files changed

Lines changed: 65 additions & 65 deletions

File tree

‎demo/res/scripts/base/kbengine.py‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,20 @@ def onGlobalDataDel(key):
7373
globalData有删除
7474
"""
7575
DEBUG_MSG('onDelGlobalData: %s' % key)
76-
77-
def onGlobalBases(key, value):
76+
77+
def onBaseAppData(key, value):
7878
"""
7979
KBEngine method.
80-
globalBases有改变
80+
baseAppData有改变
8181
"""
82-
DEBUG_MSG('onGlobalBases: %s' % key)
82+
DEBUG_MSG('onBaseAppData: %s' % key)
8383

84-
def onGlobalBasesDel(key):
84+
def onBaseAppDataDel(key):
8585
"""
8686
KBEngine method.
87-
globalBases有删除
87+
baseAppData有删除
8888
"""
89-
DEBUG_MSG('onGlobalBasesDel: %s' % key)
89+
DEBUG_MSG('onBaseAppDataDel: %s' % key)
9090

9191
def onLoseChargeCB(ordersID, dbid, success, datas):
9292
"""

‎kbe/src/lib/server/entity_app.hpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class EntityApp : public ServerApp
156156
/** 网络接口
157157
dbmgr广播global数据的改变
158158
*/
159-
void onBroadcastGlobalDataChange(Mercury::Channel* pChannel, KBEngine::MemoryStream& s);
159+
void onBroadcastGlobalDataChanged(Mercury::Channel* pChannel, KBEngine::MemoryStream& s);
160160

161161

162162
/** 网络接口
@@ -807,7 +807,7 @@ void EntityApp<E>::onDbmgrInitCompleted(Mercury::Channel* pChannel,
807807
}
808808

809809
template<class E>
810-
void EntityApp<E>::onBroadcastGlobalDataChange(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
810+
void EntityApp<E>::onBroadcastGlobalDataChanged(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
811811
{
812812
std::string key, value;
813813
bool isDelete;
@@ -823,7 +823,7 @@ void EntityApp<E>::onBroadcastGlobalDataChange(Mercury::Channel* pChannel, KBEng
823823
PyObject * pyKey = script::Pickler::unpickle(key);
824824
if(pyKey == NULL)
825825
{
826-
ERROR_MSG("EntityApp::onBroadcastCellAppDataChange: no has key!\n");
826+
ERROR_MSG("EntityApp::onBroadcastGlobalDataChanged: no has key!\n");
827827
return;
828828
}
829829

@@ -843,7 +843,7 @@ void EntityApp<E>::onBroadcastGlobalDataChange(Mercury::Channel* pChannel, KBEng
843843
PyObject * pyValue = script::Pickler::unpickle(value);
844844
if(pyValue == NULL)
845845
{
846-
ERROR_MSG("EntityApp::onBroadcastCellAppDataChange: no has value!\n");
846+
ERROR_MSG("EntityApp::onBroadcastGlobalDataChanged: no has value!\n");
847847
Py_DECREF(pyKey);
848848
return;
849849
}

‎kbe/src/lib/server/globaldata_client.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void GlobalDataClient::onDataChanged(std::string& key, std::string& value, bool
122122

123123
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
124124

125-
(*pBundle).newMessage(DbmgrInterface::onBroadcastGlobalDataChange);
125+
(*pBundle).newMessage(DbmgrInterface::onBroadcastGlobalDataChanged);
126126

127127
(*pBundle) << dataType;
128128
(*pBundle) << isDelete;

‎kbe/src/lib/server/globaldata_server.cpp‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool GlobalDataServer::write(Mercury::Channel* pChannel, COMPONENT_TYPE componen
4242
const std::string& key, const std::string& value)
4343
{
4444
// ¹ã²¥Ëù×öµÄ¸Ä±ä
45-
broadcastDataChange(pChannel, componentType, key, value);
45+
broadcastDataChanged(pChannel, componentType, key, value);
4646

4747
DATA_MAP_KEY iter = dict_.find(key);
4848
if(iter != dict_.end()){
@@ -62,15 +62,15 @@ bool GlobalDataServer::del(Mercury::Channel* pChannel, COMPONENT_TYPE componentT
6262
return false;
6363
}
6464

65-
broadcastDataChange(pChannel, componentType, key, "", true);
65+
broadcastDataChanged(pChannel, componentType, key, "", true);
6666
return true;
6767
}
6868

6969
//-------------------------------------------------------------------------------------
70-
void GlobalDataServer::broadcastDataChange(Mercury::Channel* pChannel, COMPONENT_TYPE componentType,
70+
void GlobalDataServer::broadcastDataChanged(Mercury::Channel* pChannel, COMPONENT_TYPE componentType,
7171
const std::string& key, const std::string& value, bool isDelete)
7272
{
73-
INFO_MSG(boost::format("GlobalDataServer::broadcastDataChange: writer(%1%, addr=%5%), key_size=%2%, val_size=%3%, isdelete=%4%\n") %
73+
INFO_MSG(boost::format("GlobalDataServer::broadcastDataChanged: writer(%1%, addr=%5%), key_size=%2%, val_size=%3%, isdelete=%4%\n") %
7474
COMPONENT_NAME_EX(componentType) % key.size() % value.size() % (int)isDelete % pChannel->c_str());
7575

7676
std::vector<COMPONENT_TYPE>::iterator iter = concernComponentTypes_.begin();
@@ -88,7 +88,7 @@ void GlobalDataServer::broadcastDataChange(Mercury::Channel* pChannel, COMPONENT
8888
if(pChannel == lpChannel)
8989
continue;
9090

91-
if(dataType_ == GLOBAL_BASES && iter1->componentType != BASEAPP_TYPE)
91+
if(dataType_ == BASEAPP_DATA && iter1->componentType != BASEAPP_TYPE)
9292
continue;
9393

9494
if(dataType_ == CELLAPP_DATA && iter1->componentType != CELLAPP_TYPE)
@@ -101,22 +101,22 @@ void GlobalDataServer::broadcastDataChange(Mercury::Channel* pChannel, COMPONENT
101101
case GLOBAL_DATA:
102102
if(iter1->componentType == CELLAPP_TYPE)
103103
{
104-
(*pBundle).newMessage(CellappInterface::onBroadcastGlobalDataChange);
104+
(*pBundle).newMessage(CellappInterface::onBroadcastGlobalDataChanged);
105105
}
106106
else if(iter1->componentType == BASEAPP_TYPE)
107107
{
108-
(*pBundle).newMessage(BaseappInterface::onBroadcastGlobalDataChange);
108+
(*pBundle).newMessage(BaseappInterface::onBroadcastGlobalDataChanged);
109109
}
110110
else
111111
{
112112
KBE_ASSERT(false && "componentType is error!\n");
113113
}
114114
break;
115-
case GLOBAL_BASES:
116-
(*pBundle).newMessage(BaseappInterface::onBroadcastGlobalBasesChange);
115+
case BASEAPP_DATA:
116+
(*pBundle).newMessage(BaseappInterface::onBroadcastBaseAppDataChanged);
117117
break;
118118
case CELLAPP_DATA:
119-
(*pBundle).newMessage(CellappInterface::onBroadcastCellAppDataChange);
119+
(*pBundle).newMessage(CellappInterface::onBroadcastCellAppDataChanged);
120120
break;
121121
default:
122122
KBE_ASSERT(false && "dataType is error!\n");
@@ -157,25 +157,25 @@ void GlobalDataServer::onGlobalDataClientLogon(Mercury::Channel* client, COMPONE
157157
case GLOBAL_DATA:
158158
if(componentType == CELLAPP_TYPE)
159159
{
160-
(*pBundle).newMessage(CellappInterface::onBroadcastGlobalDataChange);
160+
(*pBundle).newMessage(CellappInterface::onBroadcastGlobalDataChanged);
161161
}
162162
else if(componentType == BASEAPP_TYPE)
163163
{
164-
(*pBundle).newMessage(BaseappInterface::onBroadcastGlobalDataChange);
164+
(*pBundle).newMessage(BaseappInterface::onBroadcastGlobalDataChanged);
165165
}
166166
else
167167
{
168168
KBE_ASSERT(false && "componentType is error!\n");
169169
}
170170
break;
171-
case GLOBAL_BASES:
171+
case BASEAPP_DATA:
172172
if(componentType != BASEAPP_TYPE)
173173
{
174174
Mercury::Bundle::ObjPool().reclaimObject(pBundle);
175175
continue;
176176
}
177177

178-
(*pBundle).newMessage(BaseappInterface::onBroadcastGlobalBasesChange);
178+
(*pBundle).newMessage(BaseappInterface::onBroadcastBaseAppDataChanged);
179179
break;
180180
case CELLAPP_DATA:
181181
if(componentType != CELLAPP_TYPE)
@@ -184,7 +184,7 @@ void GlobalDataServer::onGlobalDataClientLogon(Mercury::Channel* client, COMPONE
184184
continue;
185185
}
186186

187-
(*pBundle).newMessage(CellappInterface::onBroadcastCellAppDataChange);
187+
(*pBundle).newMessage(CellappInterface::onBroadcastCellAppDataChanged);
188188
break;
189189
default:
190190
KBE_ASSERT(false && "dataType is error!\n");

‎kbe/src/lib/server/globaldata_server.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class GlobalDataServer
3535
enum DATA_TYPE
3636
{
3737
GLOBAL_DATA,
38-
GLOBAL_BASES,
38+
BASEAPP_DATA,
3939
CELLAPP_DATA
4040
};
4141
public:
@@ -52,7 +52,7 @@ class GlobalDataServer
5252
void addConcernComponentType(COMPONENT_TYPE ct){ concernComponentTypes_.push_back(ct); }
5353

5454
/** 广播一个数据的改变给所关心的组件 */
55-
void broadcastDataChange(Mercury::Channel* pChannel, COMPONENT_TYPE componentType, const std::string& key,
55+
void broadcastDataChanged(Mercury::Channel* pChannel, COMPONENT_TYPE componentType, const std::string& key,
5656
const std::string& value, bool isDelete = false);
5757

5858
/** 一个新的客户端登陆 */

‎kbe/src/server/baseapp/baseapp.cpp‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Baseapp::Baseapp(Mercury::EventDispatcher& dispatcher,
119119
COMPONENT_ID componentID):
120120
EntityApp<Base>(dispatcher, ninterface, componentType, componentID),
121121
loopCheckTimerHandle_(),
122-
pGlobalBases_(NULL),
122+
pBaseAppData_(NULL),
123123
pendingLoginMgr_(ninterface),
124124
forward_messagebuffer_(ninterface),
125125
pBackupSender_(),
@@ -265,8 +265,8 @@ bool Baseapp::installPyModules()
265265
void Baseapp::onInstallPyModules()
266266
{
267267
// 添加globalData, globalBases支持
268-
pGlobalBases_ = new GlobalDataClient(DBMGR_TYPE, GlobalDataServer::GLOBAL_BASES);
269-
registerPyObjectToScript("globalBases", pGlobalBases_);
268+
pBaseAppData_ = new GlobalDataClient(DBMGR_TYPE, GlobalDataServer::BASEAPP_DATA);
269+
registerPyObjectToScript("baseAppData", pBaseAppData_);
270270

271271
if(PyModule_AddIntMacro(this->getScript().getModule(), LOG_ON_REJECT))
272272
{
@@ -297,8 +297,8 @@ bool Baseapp::uninstallPyModules()
297297
script::PyProfile::remove("kbengine");
298298
}
299299

300-
unregisterPyObjectToScript("globalBases");
301-
S_RELEASE(pGlobalBases_);
300+
unregisterPyObjectToScript("baseAppData");
301+
S_RELEASE(pBaseAppData_);
302302

303303
Base::uninstallScript();
304304
Proxy::uninstallScript();
@@ -1807,7 +1807,7 @@ void Baseapp::onDbmgrInitCompleted(Mercury::Channel* pChannel,
18071807
}
18081808

18091809
//-------------------------------------------------------------------------------------
1810-
void Baseapp::onBroadcastGlobalBasesChange(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
1810+
void Baseapp::onBroadcastBaseAppDataChanged(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
18111811
{
18121812
if(pChannel->isExternal())
18131813
return;
@@ -1827,20 +1827,20 @@ void Baseapp::onBroadcastGlobalBasesChange(Mercury::Channel* pChannel, KBEngine:
18271827
PyObject * pyKey = script::Pickler::unpickle(key);
18281828
if(pyKey == NULL)
18291829
{
1830-
ERROR_MSG("Baseapp::onBroadcastCellAppDataChange: no has key!\n");
1830+
ERROR_MSG("Baseapp::onBroadcastBaseAppDataChanged: no has key!\n");
18311831
return;
18321832
}
18331833

18341834
Py_INCREF(pyKey);
18351835

18361836
if(isDelete)
18371837
{
1838-
if(pGlobalBases_->del(pyKey))
1838+
if(pBaseAppData_->del(pyKey))
18391839
{
18401840
SCOPED_PROFILE(SCRIPTCALL_PROFILE);
18411841

18421842
// 通知脚本
1843-
SCRIPT_OBJECT_CALL_ARGS1(getEntryScript().get(), const_cast<char*>("onGlobalBasesDel"),
1843+
SCRIPT_OBJECT_CALL_ARGS1(getEntryScript().get(), const_cast<char*>("onBaseAppDataDel"),
18441844
const_cast<char*>("O"), pyKey);
18451845
}
18461846
}
@@ -1849,19 +1849,19 @@ void Baseapp::onBroadcastGlobalBasesChange(Mercury::Channel* pChannel, KBEngine:
18491849
PyObject * pyValue = script::Pickler::unpickle(value);
18501850
if(pyValue == NULL)
18511851
{
1852-
ERROR_MSG("Baseapp::onBroadcastCellAppDataChange: no has value!\n");
1852+
ERROR_MSG("Baseapp::onBroadcastBaseAppDataChanged: no has value!\n");
18531853
Py_DECREF(pyKey);
18541854
return;
18551855
}
18561856

18571857
Py_INCREF(pyValue);
18581858

1859-
if(pGlobalBases_->write(pyKey, pyValue))
1859+
if(pBaseAppData_->write(pyKey, pyValue))
18601860
{
18611861
SCOPED_PROFILE(SCRIPTCALL_PROFILE);
18621862

18631863
// 通知脚本
1864-
SCRIPT_OBJECT_CALL_ARGS2(getEntryScript().get(), const_cast<char*>("onGlobalBases"),
1864+
SCRIPT_OBJECT_CALL_ARGS2(getEntryScript().get(), const_cast<char*>("onBaseAppData"),
18651865
const_cast<char*>("OO"), pyKey, pyValue);
18661866
}
18671867

‎kbe/src/server/baseapp/baseapp.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class Baseapp : public EntityApp<Base>,
218218
/** 网络接口
219219
dbmgr广播global数据的改变
220220
*/
221-
void onBroadcastGlobalBasesChange(Mercury::Channel* pChannel, KBEngine::MemoryStream& s);
221+
void onBroadcastBaseAppDataChanged(Mercury::Channel* pChannel, KBEngine::MemoryStream& s);
222222

223223
/** 网络接口
224224
注册将要登录的账号, 注册后则允许登录到此网关
@@ -414,7 +414,7 @@ class Baseapp : public EntityApp<Base>,
414414
protected:
415415
TimerHandle loopCheckTimerHandle_;
416416

417-
GlobalDataClient* pGlobalBases_; // globalBases
417+
GlobalDataClient* pBaseAppData_; // globalBases
418418

419419
// 记录登录到服务器但还未处理完毕的账号
420420
PendingLoginMgr pendingLoginMgr_;

‎kbe/src/server/baseapp/baseapp_interface.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ NETWORK_INTERFACE_DECLARE_BEGIN(BaseappInterface)
114114
BASEAPP_MESSAGE_DECLARE_STREAM(hello, MERCURY_VARIABLE_MESSAGE)
115115

116116
// global数据改变
117-
BASEAPP_MESSAGE_DECLARE_STREAM(onBroadcastGlobalDataChange, MERCURY_VARIABLE_MESSAGE)
118-
BASEAPP_MESSAGE_DECLARE_STREAM(onBroadcastGlobalBasesChange, MERCURY_VARIABLE_MESSAGE)
117+
BASEAPP_MESSAGE_DECLARE_STREAM(onBroadcastGlobalDataChanged, MERCURY_VARIABLE_MESSAGE)
118+
BASEAPP_MESSAGE_DECLARE_STREAM(onBroadcastBaseAppDataChanged, MERCURY_VARIABLE_MESSAGE)
119119

120120
// 某个app向本app告知处于活动状态。
121121
BASEAPP_MESSAGE_DECLARE_ARGS2(onAppActiveTick, MERCURY_FIXED_MESSAGE,

‎kbe/src/server/cellapp/cellapp.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ void Cellapp::onDbmgrInitCompleted(Mercury::Channel* pChannel,
611611
}
612612

613613
//-------------------------------------------------------------------------------------
614-
void Cellapp::onBroadcastCellAppDataChange(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
614+
void Cellapp::onBroadcastCellAppDataChanged(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
615615
{
616616

617617
std::string key, value;
@@ -628,7 +628,7 @@ void Cellapp::onBroadcastCellAppDataChange(Mercury::Channel* pChannel, KBEngine:
628628
PyObject * pyKey = script::Pickler::unpickle(key);
629629
if(pyKey == NULL)
630630
{
631-
ERROR_MSG("Cellapp::onBroadcastCellAppDataChange: no has key!\n");
631+
ERROR_MSG("Cellapp::onBroadcastCellAppDataChanged: no has key!\n");
632632
return;
633633
}
634634

@@ -651,7 +651,7 @@ void Cellapp::onBroadcastCellAppDataChange(Mercury::Channel* pChannel, KBEngine:
651651

652652
if(pyValue == NULL)
653653
{
654-
ERROR_MSG("Cellapp::onBroadcastCellAppDataChange: no has value!\n");
654+
ERROR_MSG("Cellapp::onBroadcastCellAppDataChanged: no has value!\n");
655655
Py_DECREF(pyKey);
656656
return;
657657
}

‎kbe/src/server/cellapp/cellapp.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class Cellapp: public EntityApp<Entity>,
116116
/** 网络接口
117117
dbmgr广播global数据的改变
118118
*/
119-
void onBroadcastCellAppDataChange(Mercury::Channel* pChannel, KBEngine::MemoryStream& s);
119+
void onBroadcastCellAppDataChanged(Mercury::Channel* pChannel, KBEngine::MemoryStream& s);
120120

121121
/** 网络接口
122122
baseEntity请求创建在一个新的space中

0 commit comments

Comments
 (0)