Repository navigation
Expand file tree
/
Copy pathdbmgr.cpp
More file actions
691 lines (575 loc) · 22.8 KB
/
Copy pathdbmgr.cpp
File metadata and controls
691 lines (575 loc) · 22.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
/*
This source file is part of KBEngine
For the latest info, see http://www.kbengine.org/
Copyright (c) 2008-2012 KBEngine.
KBEngine is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
KBEngine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dbmgr.hpp"
#include "dbmgr_interface.hpp"
#include "dbtasks.hpp"
#include "billinghandler.hpp"
#include "sync_app_datas_handler.hpp"
#include "db_mysql/kbe_table_mysql.hpp"
#include "network/common.hpp"
#include "network/tcp_packet.hpp"
#include "network/udp_packet.hpp"
#include "network/message_handler.hpp"
#include "thread/threadpool.hpp"
#include "server/componentbridge.hpp"
#include "server/components.hpp"
#include "dbmgr_lib/db_interface.hpp"
#include "db_mysql/db_interface_mysql.hpp"
#include "entitydef/scriptdef_module.hpp"
#include "baseapp/baseapp_interface.hpp"
#include "cellapp/cellapp_interface.hpp"
#include "baseappmgr/baseappmgr_interface.hpp"
#include "cellappmgr/cellappmgr_interface.hpp"
#include "loginapp/loginapp_interface.hpp"
namespace KBEngine{
ServerConfig g_serverConfig;
KBE_SINGLETON_INIT(Dbmgr);
//-------------------------------------------------------------------------------------
Dbmgr::Dbmgr(Mercury::EventDispatcher& dispatcher,
Mercury::NetworkInterface& ninterface,
COMPONENT_TYPE componentType,
COMPONENT_ID componentID):
ServerApp(dispatcher, ninterface, componentType, componentID),
loopCheckTimerHandle_(),
mainProcessTimer_(),
idServer_(1, 1024),
pGlobalData_(NULL),
pBaseAppData_(NULL),
pCellAppData_(NULL),
bufferedDBTasks_(),
dbThreadPool_(),
numWrittenEntity_(0),
numRemovedEntity_(0),
numQueryEntity_(0),
numExecuteRawDatabaseCommand_(0),
numCreatedAccount_(0),
pBillingAccountHandler_(NULL),
pBillingChargeHandler_(NULL),
pSyncAppDatasHandler_(NULL)
{
}
//-------------------------------------------------------------------------------------
Dbmgr::~Dbmgr()
{
loopCheckTimerHandle_.cancel();
mainProcessTimer_.cancel();
KBEngine::sleep(300);
SAFE_RELEASE(pBillingAccountHandler_);
SAFE_RELEASE(pBillingChargeHandler_);
}
//-------------------------------------------------------------------------------------
bool Dbmgr::canShutdown()
{
bool ret = bufferedDBTasks_.size() == 0;
if(ret)
{
WARNING_MSG(boost::format("Dbmgr::canShutdown(): tasks=%1%, threads=%2%, threadpoolDestroyed=%3%!\n") %
bufferedDBTasks_.size() % dbThreadPool_.getCurrentThreadCount() % dbThreadPool_.isDestroyed());
}
return ret;
}
//-------------------------------------------------------------------------------------
bool Dbmgr::initializeWatcher()
{
WATCH_OBJECT("numWrittenEntity", numWrittenEntity_);
WATCH_OBJECT("numRemovedEntity", numRemovedEntity_);
WATCH_OBJECT("numQueryEntity", numQueryEntity_);
WATCH_OBJECT("numExecuteRawDatabaseCommand", numExecuteRawDatabaseCommand_);
WATCH_OBJECT("numCreatedAccount", numCreatedAccount_);
return ServerApp::initializeWatcher();
}
//-------------------------------------------------------------------------------------
bool Dbmgr::run()
{
return ServerApp::run();
}
//-------------------------------------------------------------------------------------
void Dbmgr::handleTimeout(TimerHandle handle, void * arg)
{
switch (reinterpret_cast<uintptr>(arg))
{
case TIMEOUT_TICK:
this->handleMainTick();
break;
case TIMEOUT_CHECK_STATUS:
this->handleCheckStatusTick();
break;
default:
break;
}
ServerApp::handleTimeout(handle, arg);
}
//-------------------------------------------------------------------------------------
void Dbmgr::handleMainTick()
{
//time_t t = ::time(NULL);
//DEBUG_MSG("Dbmgr::handleGameTick[%"PRTime"]:%u\n", t, time_);
g_kbetime++;
threadPool_.onMainThreadTick();
dbThreadPool_.onMainThreadTick();
getNetworkInterface().processAllChannelPackets(&DbmgrInterface::messageHandlers);
}
//-------------------------------------------------------------------------------------
void Dbmgr::handleCheckStatusTick()
{
}
//-------------------------------------------------------------------------------------
bool Dbmgr::initializeBegin()
{
return true;
}
//-------------------------------------------------------------------------------------
bool Dbmgr::inInitialize()
{
// 初始化所有扩展模块
// demo/res/scripts/
std::vector<PyTypeObject*> scriptBaseTypes;
if(!EntityDef::initialize(scriptBaseTypes, componentType_)){
return false;
}
return true;
}
//-------------------------------------------------------------------------------------
bool Dbmgr::initializeEnd()
{
// 添加一个timer, 每秒检查一些状态
loopCheckTimerHandle_ = this->getMainDispatcher().addTimer(1000000, this,
reinterpret_cast<void *>(TIMEOUT_CHECK_STATUS));
mainProcessTimer_ = this->getMainDispatcher().addTimer(1000000 / g_kbeSrvConfig.gameUpdateHertz(), this,
reinterpret_cast<void *>(TIMEOUT_TICK));
// 添加globalData, baseAppData, cellAppData支持
pGlobalData_ = new GlobalDataServer(GlobalDataServer::GLOBAL_DATA);
pBaseAppData_ = new GlobalDataServer(GlobalDataServer::BASEAPP_DATA);
pCellAppData_ = new GlobalDataServer(GlobalDataServer::CELLAPP_DATA);
pGlobalData_->addConcernComponentType(CELLAPP_TYPE);
pGlobalData_->addConcernComponentType(BASEAPP_TYPE);
pBaseAppData_->addConcernComponentType(BASEAPP_TYPE);
pCellAppData_->addConcernComponentType(CELLAPP_TYPE);
INFO_MSG(boost::format("Dbmgr::initializeEnd: digest(%1%)\n") %
EntityDef::md5().getDigestStr());
return initBillingHandler() && initDB();
}
//-------------------------------------------------------------------------------------
bool Dbmgr::initBillingHandler()
{
pBillingAccountHandler_ = BillingHandlerFactory::create(g_kbeSrvConfig.billingSystemAccountType(), threadPool(), dbThreadPool_);
pBillingChargeHandler_ = BillingHandlerFactory::create(g_kbeSrvConfig.billingSystemChargeType(), threadPool(), dbThreadPool_);
INFO_MSG(boost::format("Dbmgr::initBillingHandler: billing addr(%1%), accountType:(%2%), chargeType:(%3%).\n") %
g_kbeSrvConfig.billingSystemAddr().c_str() %
g_kbeSrvConfig.billingSystemAccountType() %
g_kbeSrvConfig.billingSystemChargeType());
if(strlen(g_kbeSrvConfig.billingSystemThirdpartyAccountServiceAddr()) > 0)
{
INFO_MSG(boost::format("Dbmgr::initBillingHandler: thirdpartyAccountService_addr(%1%:%2%).\n") %
g_kbeSrvConfig.billingSystemThirdpartyAccountServiceAddr() %
g_kbeSrvConfig.billingSystemThirdpartyAccountServicePort());
}
if(strlen(g_kbeSrvConfig.billingSystemThirdpartyChargeServiceAddr()) > 0)
{
INFO_MSG(boost::format("Dbmgr::initBillingHandler: thirdpartyChargeService_addr(%1%:%2%).\n") %
g_kbeSrvConfig.billingSystemThirdpartyChargeServiceAddr() %
g_kbeSrvConfig.billingSystemThirdpartyChargeServicePort());
}
return pBillingAccountHandler_->initialize() && pBillingChargeHandler_->initialize();
}
//-------------------------------------------------------------------------------------
bool Dbmgr::initDB()
{
if(!DBUtil::initialize())
{
ERROR_MSG("Dbmgr::initDB: can't initialize dbinterface!\n");
return false;
}
ENGINE_COMPONENT_INFO& dbcfg = g_kbeSrvConfig.getDBMgr();
DBInterface* pDBInterface = DBUtil::createInterface();
if(pDBInterface == NULL)
{
ERROR_MSG("Dbmgr::initDB: can't create dbinterface!\n");
return false;
}
bool ret = DBUtil::initInterface(pDBInterface);
if(ret)
{
ret = pDBInterface->checkEnvironment();
}
pDBInterface->detach();
SAFE_RELEASE(pDBInterface);
if(!ret)
return false;
if(!dbThreadPool_.isInitialize())
{
ret = dbThreadPool_.createThreadPool(dbcfg.db_numConnections,
dbcfg.db_numConnections, dbcfg.db_numConnections);
}
return ret;
}
//-------------------------------------------------------------------------------------
void Dbmgr::finalise()
{
SAFE_RELEASE(pGlobalData_);
SAFE_RELEASE(pBaseAppData_);
SAFE_RELEASE(pCellAppData_);
dbThreadPool_.finalise();
ServerApp::finalise();
}
//-------------------------------------------------------------------------------------
void Dbmgr::onReqAllocEntityID(Mercury::Channel* pChannel, int8 componentType, COMPONENT_ID componentID)
{
KBEngine::COMPONENT_TYPE ct = static_cast<KBEngine::COMPONENT_TYPE>(componentType);
// 获取一个id段 并传输给IDClient
std::pair<ENTITY_ID, ENTITY_ID> idRange = idServer_.allocRange();
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
if(ct == BASEAPP_TYPE)
(*pBundle).newMessage(BaseappInterface::onReqAllocEntityID);
else
(*pBundle).newMessage(CellappInterface::onReqAllocEntityID);
(*pBundle) << idRange.first;
(*pBundle) << idRange.second;
(*pBundle).send(this->getNetworkInterface(), pChannel);
Mercury::Bundle::ObjPool().reclaimObject(pBundle);
}
//-------------------------------------------------------------------------------------
void Dbmgr::onRegisterNewApp(Mercury::Channel* pChannel, int32 uid, std::string& username,
int8 componentType, uint64 componentID, int8 globalorderID, int8 grouporderID,
uint32 intaddr, uint16 intport, uint32 extaddr, uint16 extport, std::string& extaddrEx)
{
ServerApp::onRegisterNewApp(pChannel, uid, username, componentType, componentID, globalorderID, grouporderID,
intaddr, intport, extaddr, extport, extaddrEx);
KBEngine::COMPONENT_TYPE tcomponentType = (KBEngine::COMPONENT_TYPE)componentType;
int32 startGroupOrder = 1;
int32 startGlobalOrder = Componentbridge::getComponents().getGlobalOrderLog()[getUserUID()];
if(grouporderID > 0)
startGroupOrder = grouporderID;
if(globalorderID > 0)
startGlobalOrder = globalorderID;
if(pSyncAppDatasHandler_ == NULL)
pSyncAppDatasHandler_ = new SyncAppDatasHandler(this->getNetworkInterface());
// 下一步:
// 如果是连接到dbmgr则需要等待接收app初始信息
// 例如:初始会分配entityID段以及这个app启动的顺序信息(是否第一个baseapp启动)
if(tcomponentType == BASEAPP_TYPE ||
tcomponentType == CELLAPP_TYPE ||
tcomponentType == LOGINAPP_TYPE)
{
switch(tcomponentType)
{
case BASEAPP_TYPE:
{
if(grouporderID <= 0)
startGroupOrder = Componentbridge::getComponents().getBaseappGroupOrderLog()[getUserUID()];
}
break;
case CELLAPP_TYPE:
{
if(grouporderID <= 0)
startGroupOrder = Componentbridge::getComponents().getCellappGroupOrderLog()[getUserUID()];
}
break;
case LOGINAPP_TYPE:
if(grouporderID <= 0)
startGroupOrder = Componentbridge::getComponents().getLoginappGroupOrderLog()[getUserUID()];
break;
default:
break;
}
}
pSyncAppDatasHandler_->pushApp(componentID, startGroupOrder, startGlobalOrder);
// 如果是baseapp或者cellapp则将自己注册到所有其他baseapp和cellapp
if(tcomponentType == BASEAPP_TYPE ||
tcomponentType == CELLAPP_TYPE)
{
KBEngine::COMPONENT_TYPE broadcastCpTypes[2] = {BASEAPP_TYPE, CELLAPP_TYPE};
for(int idx = 0; idx < 2; idx++)
{
Components::COMPONENTS& cts = Components::getSingleton().getComponents(broadcastCpTypes[idx]);
Components::COMPONENTS::iterator fiter = cts.begin();
for(; fiter != cts.end(); fiter++)
{
if((*fiter).cid == componentID)
continue;
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
ENTITTAPP_COMMON_MERCURY_MESSAGE(broadcastCpTypes[idx], (*pBundle), onGetEntityAppFromDbmgr);
if(tcomponentType == BASEAPP_TYPE)
{
BaseappInterface::onGetEntityAppFromDbmgrArgs11::staticAddToBundle((*pBundle),
uid, username, componentType, componentID, startGlobalOrder, startGroupOrder,
intaddr, intport, extaddr, extport, g_kbeSrvConfig.getConfig().externalAddress);
}
else
{
CellappInterface::onGetEntityAppFromDbmgrArgs11::staticAddToBundle((*pBundle),
uid, username, componentType, componentID, startGlobalOrder, startGroupOrder,
intaddr, intport, extaddr, extport, g_kbeSrvConfig.getConfig().externalAddress);
}
KBE_ASSERT((*fiter).pChannel != NULL);
(*pBundle).send(networkInterface_, (*fiter).pChannel);
Mercury::Bundle::ObjPool().reclaimObject(pBundle);
}
}
}
}
//-------------------------------------------------------------------------------------
void Dbmgr::onGlobalDataClientLogon(Mercury::Channel* pChannel, COMPONENT_TYPE componentType)
{
if(BASEAPP_TYPE == componentType)
{
pBaseAppData_->onGlobalDataClientLogon(pChannel, componentType);
pGlobalData_->onGlobalDataClientLogon(pChannel, componentType);
}
else if(CELLAPP_TYPE == componentType)
{
pGlobalData_->onGlobalDataClientLogon(pChannel, componentType);
pCellAppData_->onGlobalDataClientLogon(pChannel, componentType);
}
else
{
ERROR_MSG(boost::format("Dbmgr::onGlobalDataClientLogon: nonsupport %1%!\n") %
COMPONENT_NAME_EX(componentType));
}
}
//-------------------------------------------------------------------------------------
void Dbmgr::onBroadcastGlobalDataChanged(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
uint8 dataType;
std::string key, value;
bool isDelete;
COMPONENT_TYPE componentType;
s >> dataType;
s >> isDelete;
s.readBlob(key);
if(!isDelete)
{
s.readBlob(value);
}
s >> componentType;
switch(dataType)
{
case GlobalDataServer::GLOBAL_DATA:
if(isDelete)
pGlobalData_->del(pChannel, componentType, key);
else
pGlobalData_->write(pChannel, componentType, key, value);
break;
case GlobalDataServer::BASEAPP_DATA:
if(isDelete)
pBaseAppData_->del(pChannel, componentType, key);
else
pBaseAppData_->write(pChannel, componentType, key, value);
break;
case GlobalDataServer::CELLAPP_DATA:
if(isDelete)
pCellAppData_->del(pChannel, componentType, key);
else
pCellAppData_->write(pChannel, componentType, key, value);
break;
default:
KBE_ASSERT(false && "dataType is error!\n");
break;
};
}
//-------------------------------------------------------------------------------------
void Dbmgr::reqCreateAccount(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
std::string registerName, password, datas;
uint8 uatype = 0;
s >> registerName >> password >> uatype;
s.readBlob(datas);
if(registerName.size() == 0)
{
ERROR_MSG("Dbmgr::reqCreateAccount: registerName is empty.\n");
return;
}
pBillingAccountHandler_->createAccount(pChannel, registerName, password, datas, ACCOUNT_TYPE(uatype));
numCreatedAccount_++;
}
//-------------------------------------------------------------------------------------
void Dbmgr::onCreateAccountCBFromBilling(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
pBillingAccountHandler_->onCreateAccountCB(s);
}
//-------------------------------------------------------------------------------------
void Dbmgr::onAccountLogin(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
std::string loginName, password, datas;
s >> loginName >> password;
s.readBlob(datas);
if(loginName.size() == 0)
{
ERROR_MSG("Dbmgr::onAccountLogin: loginName is empty.\n");
return;
}
pBillingAccountHandler_->loginAccount(pChannel, loginName, password, datas);
}
//-------------------------------------------------------------------------------------
void Dbmgr::onLoginAccountCBBFromBilling(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
pBillingAccountHandler_->onLoginAccountCB(s);
}
//-------------------------------------------------------------------------------------
void Dbmgr::queryAccount(Mercury::Channel* pChannel,
std::string& accountName,
std::string& password,
COMPONENT_ID componentID,
ENTITY_ID entityID,
DBID entityDBID,
uint32 ip,
uint16 port)
{
if(accountName.size() == 0)
{
ERROR_MSG("Dbmgr::queryAccount: accountName is empty.\n");
return;
}
bufferedDBTasks_.addTask(new DBTaskQueryAccount(pChannel->addr(),
accountName, password, componentID, entityID, entityDBID, ip, port));
numQueryEntity_++;
}
//-------------------------------------------------------------------------------------
void Dbmgr::onAccountOnline(Mercury::Channel* pChannel,
std::string& accountName,
COMPONENT_ID componentID,
ENTITY_ID entityID)
{
// PUSH_THREAD_TASK(new DBTaskAccountOnline(pChannel->addr(),
// accountName, componentID, entityID));
}
//-------------------------------------------------------------------------------------
void Dbmgr::onEntityOffline(Mercury::Channel* pChannel, DBID dbid, ENTITY_SCRIPT_UID sid)
{
dbThreadPool_.addTask(new DBTaskEntityOffline(pChannel->addr(), dbid, sid));
}
//-------------------------------------------------------------------------------------
void Dbmgr::executeRawDatabaseCommand(Mercury::Channel* pChannel,
KBEngine::MemoryStream& s)
{
ENTITY_ID entityID = -1;
s >> entityID;
if(entityID == -1)
dbThreadPool_.addTask(new DBTaskExecuteRawDatabaseCommand(pChannel->addr(), s));
else
bufferedDBTasks_.addTask(new DBTaskExecuteRawDatabaseCommandByEntity(pChannel->addr(), s, entityID));
s.opfini();
numExecuteRawDatabaseCommand_++;
}
//-------------------------------------------------------------------------------------
void Dbmgr::writeEntity(Mercury::Channel* pChannel,
KBEngine::MemoryStream& s)
{
ENTITY_ID eid;
DBID entityDBID;
COMPONENT_ID componentID;
s >> componentID >> eid >> entityDBID;
bufferedDBTasks_.addTask(new DBTaskWriteEntity(pChannel->addr(), componentID, eid, entityDBID, s));
s.opfini();
numWrittenEntity_++;
}
//-------------------------------------------------------------------------------------
void Dbmgr::removeEntity(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
ENTITY_ID eid;
DBID entityDBID;
COMPONENT_ID componentID;
s >> componentID >> eid >> entityDBID;
KBE_ASSERT(entityDBID > 0);
bufferedDBTasks_.addTask(new DBTaskRemoveEntity(pChannel->addr(),
componentID, eid, entityDBID, s));
s.opfini();
numRemovedEntity_++;
}
//-------------------------------------------------------------------------------------
void Dbmgr::deleteBaseByDBID(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
COMPONENT_ID componentID;
ENTITY_SCRIPT_UID sid;
CALLBACK_ID callbackID = 0;
DBID entityDBID;
s >> componentID >> entityDBID >> callbackID >> sid;
KBE_ASSERT(entityDBID > 0);
dbThreadPool_.addTask(new DBTaskDeleteBaseByDBID(pChannel->addr(),
componentID, entityDBID, callbackID, sid));
}
//-------------------------------------------------------------------------------------
void Dbmgr::queryEntity(Mercury::Channel* pChannel, COMPONENT_ID componentID, int8 queryMode, DBID dbid,
std::string& entityType, CALLBACK_ID callbackID, ENTITY_ID entityID)
{
bufferedDBTasks_.addTask(new DBTaskQueryEntity(pChannel->addr(), queryMode, entityType,
dbid, componentID, callbackID, entityID));
numQueryEntity_++;
}
//-------------------------------------------------------------------------------------
void Dbmgr::syncEntityStreamTemplate(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
KBEAccountTable* pTable =
static_cast<KBEAccountTable*>(EntityTables::getSingleton().findKBETable("kbe_accountinfos"));
KBE_ASSERT(pTable);
pTable->accountDefMemoryStream(s);
s.opfini();
}
//-------------------------------------------------------------------------------------
void Dbmgr::charge(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
pBillingChargeHandler_->charge(pChannel, s);
}
//-------------------------------------------------------------------------------------
void Dbmgr::onChargeCB(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
pBillingChargeHandler_->onChargeCB(s);
}
//-------------------------------------------------------------------------------------
void Dbmgr::eraseClientReq(Mercury::Channel* pChannel, std::string& logkey)
{
pBillingAccountHandler_->eraseClientReq(pChannel, logkey);
}
//-------------------------------------------------------------------------------------
void Dbmgr::accountActivate(Mercury::Channel* pChannel, std::string& scode)
{
INFO_MSG(boost::format("Dbmgr::accountActivate: code=%1%.\n") % scode);
pBillingAccountHandler_->accountActivate(pChannel, scode);
}
//-------------------------------------------------------------------------------------
void Dbmgr::accountReqResetPassword(Mercury::Channel* pChannel, std::string& accountName)
{
INFO_MSG(boost::format("Dbmgr::accountReqResetPassword: accountName=%1%.\n") % accountName);
pBillingAccountHandler_->accountReqResetPassword(pChannel, accountName);
}
//-------------------------------------------------------------------------------------
void Dbmgr::accountResetPassword(Mercury::Channel* pChannel, std::string& accountName, std::string& newpassword, std::string& code)
{
INFO_MSG(boost::format("Dbmgr::accountResetPassword: accountName=%1%.\n") % accountName);
pBillingAccountHandler_->accountResetPassword(pChannel, accountName, newpassword, code);
}
//-------------------------------------------------------------------------------------
void Dbmgr::accountReqBindMail(Mercury::Channel* pChannel, ENTITY_ID entityID, std::string& accountName,
std::string& password, std::string& email)
{
INFO_MSG(boost::format("Dbmgr::accountReqBindMail: accountName=%1%, email=%2%.\n") % accountName % email);
pBillingAccountHandler_->accountReqBindMail(pChannel, entityID, accountName, password, email);
}
//-------------------------------------------------------------------------------------
void Dbmgr::accountBindMail(Mercury::Channel* pChannel, std::string& username, std::string& scode)
{
INFO_MSG(boost::format("Dbmgr::accountBindMail: username=%1%, scode=%2%.\n") % username % scode);
pBillingAccountHandler_->accountBindMail(pChannel, username, scode);
}
//-------------------------------------------------------------------------------------
void Dbmgr::accountNewPassword(Mercury::Channel* pChannel, ENTITY_ID entityID, std::string& accountName,
std::string& password, std::string& newpassword)
{
INFO_MSG(boost::format("Dbmgr::accountNewPassword: accountName=%1%.\n") % accountName);
pBillingAccountHandler_->accountNewPassword(pChannel, entityID, accountName, password, newpassword);
}
//-------------------------------------------------------------------------------------
}