//------------------------------------------------------------------------------------- void Dbmgr::removeEntity(Network::Channel* pChannel, KBEngine::MemoryStream& s) { ENTITY_ID eid; DBID entityDBID; COMPONENT_ID componentID; uint16 dbInterfaceIndex; s >> dbInterfaceIndex >> componentID >> eid >> entityDBID; KBE_ASSERT(entityDBID > 0); Buffered_DBTasks* pBuffered_DBTasks = findBufferedDBTask(g_kbeSrvConfig.dbInterfaceIndex2dbInterfaceName(dbInterfaceIndex)); if (!pBuffered_DBTasks) { ERROR_MSG(fmt::format("Dbmgr::removeEntity: not found dbInterfaceIndex({})!\n", dbInterfaceIndex)); s.done(); return; } pBuffered_DBTasks->addTask(new DBTaskRemoveEntity(pChannel->addr(), componentID, eid, entityDBID, s)); s.done(); ++numRemovedEntity_; }
//------------------------------------------------------------------------------------- void BillingHandler_ThirdParty::onLoginAccountCB(KBEngine::MemoryStream& s) { std::string loginName, accountName, password, postdatas, getdatas; COMPONENT_ID cid; SERVER_ERROR_CODE success = SERVER_ERR_OP_FAILED; s >> cid >> loginName >> accountName >> password >> success; s.readBlob(postdatas); s.readBlob(getdatas); if(!success) { accountName = ""; } Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(LOGINAPP_TYPE, cid); if(cinfos == NULL || cinfos->pChannel == NULL) { ERROR_MSG("BillingHandler_ThirdParty::onCreateAccountCB: loginapp not found!\n"); return; } dbThreadPool_.addTask(new DBTaskAccountLogin(cinfos->pChannel->addr(), loginName, accountName, password, success, postdatas, getdatas)); }
void EntityApp<E>::onBroadcastGlobalDataChange(Mercury::Channel* pChannel, KBEngine::MemoryStream& s) { std::string key, value; bool isDelete; s >> isDelete; s.readBlob(key); if(!isDelete) { s.readBlob(value); } PyObject * pyKey = script::Pickler::unpickle(key); if(pyKey == NULL) { ERROR_MSG("EntityApp::onBroadcastCellAppDataChange: no has key!\n"); return; } Py_INCREF(pyKey); if(isDelete) { if(pGlobalData_->del(pyKey)) { // 通知脚本 SCRIPT_OBJECT_CALL_ARGS1(getEntryScript().get(), const_cast<char*>("onGlobalDataDel"), const_cast<char*>("O"), pyKey); } } else { PyObject * pyValue = script::Pickler::unpickle(value); if(pyValue == NULL) { ERROR_MSG("EntityApp::onBroadcastCellAppDataChange: no has value!\n"); Py_DECREF(pyKey); return; } Py_INCREF(pyValue); if(pGlobalData_->write(pyKey, pyValue)) { // 通知脚本 SCRIPT_OBJECT_CALL_ARGS2(getEntryScript().get(), const_cast<char*>("onGlobalData"), const_cast<char*>("OO"), pyKey, pyValue); } Py_DECREF(pyValue); } Py_DECREF(pyKey); }
void EntityApp<E>::onExecScriptCommand(Mercury::Channel* pChannel, KBEngine::MemoryStream& s) { std::string cmd; s.readBlob(cmd); PyObject* pycmd = PyUnicode_DecodeUTF8(cmd.data(), cmd.size(), NULL); if(pycmd == NULL) { SCRIPT_ERROR_CHECK(); return; } DEBUG_MSG(boost::format("EntityApp::onExecScriptCommand: size(%1%), command=%2%.\n") % cmd.size() % cmd); std::string retbuf = ""; PyObject* pycmd1 = PyUnicode_AsEncodedString(pycmd, "utf-8", NULL); if(script_.run_simpleString(PyBytes_AsString(pycmd1), &retbuf) == 0) { // 将结果返回给客户端 Mercury::Bundle bundle; ConsoleInterface::ConsoleExecCommandCBMessageHandler msgHandler; bundle.newMessage(msgHandler); ConsoleInterface::ConsoleExecCommandCBMessageHandlerArgs1::staticAddToBundle(bundle, retbuf); bundle.send(this->getNetworkInterface(), pChannel); } Py_DECREF(pycmd); Py_DECREF(pycmd1); }
//------------------------------------------------------------------------------------- void PythonApp::onExecScriptCommand(Network::Channel* pChannel, KBEngine::MemoryStream& s) { std::string cmd; s.readBlob(cmd); PyObject* pycmd = PyUnicode_DecodeUTF8(cmd.data(), cmd.size(), NULL); if(pycmd == NULL) { SCRIPT_ERROR_CHECK(); return; } DEBUG_MSG(fmt::format("PythonApp::onExecScriptCommand: size({}), command={}.\n", cmd.size(), cmd)); std::string retbuf = ""; PyObject* pycmd1 = PyUnicode_AsEncodedString(pycmd, "utf-8", NULL); script_.run_simpleString(PyBytes_AsString(pycmd1), &retbuf); if(retbuf.size() == 0) { retbuf = "\r\n"; } // 将结果返回给客户端 Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject(); ConsoleInterface::ConsoleExecCommandCBMessageHandler msgHandler; (*pBundle).newMessage(msgHandler); ConsoleInterface::ConsoleExecCommandCBMessageHandlerArgs1::staticAddToBundle((*pBundle), retbuf); pChannel->send(pBundle); Py_DECREF(pycmd); Py_DECREF(pycmd1); }
void CWatcherWindow::onReceiveWatcherData(KBEngine::MemoryStream& s) { uint8 type = 0; s >> type; if(type == 0) { KBEngine::WatcherPaths watcherPaths; while(s.length() > 0) { std::string path; s >> path; std::string name; s >> name; KBEngine::WATCHER_ID id = 0; s >> id; KBEngine::WATCHER_VALUE_TYPE type; s >> type; KBEngine::WatcherObject* wo = watcherPaths.addWatcherFromStream(path, name, id, type, &s); addHeader(name); addItem(wo); }; }
//------------------------------------------------------------------------------------- void BillingSystem::onAccountLogin(Mercury::Channel* pChannel, KBEngine::MemoryStream& s) { std::string loginName, accountName, password, datas; COMPONENT_ID cid; s >> cid >> loginName >> password; s.readBlob(datas); lockthread(); REQLOGIN_MAP::iterator iter = reqAccountLogin_requests_.find(loginName); if(iter != reqAccountLogin_requests_.end()) { unlockthread(); return; } LoginAccountTask* pinfo = new LoginAccountTask(); pinfo->commitName = loginName; pinfo->accountName = loginName; pinfo->getDatas = ""; pinfo->password = password; pinfo->postDatas = datas; pinfo->success = false; pinfo->baseappID = cid; pinfo->dbmgrID = pChannel->componentID(); pinfo->address = pChannel->addr(); reqAccountLogin_requests_[pinfo->commitName] = pinfo; unlockthread(); this->threadPool().addTask(pinfo); }
//------------------------------------------------------------------------------------- void BillingSystem::charge(Mercury::Channel* pChannel, KBEngine::MemoryStream& s) { OrdersCharge* pOrdersCharge = new OrdersCharge(); pOrdersCharge->dbmgrID = pChannel->componentID(); pOrdersCharge->address = pChannel->addr(); s >> pOrdersCharge->baseappID; s >> pOrdersCharge->ordersID; s >> pOrdersCharge->dbid; s.readBlob(pOrdersCharge->postDatas); s >> pOrdersCharge->cbid; INFO_MSG(boost::format("BillingSystem::charge: componentID=%5%, chargeID=%1%, dbid=%2%, cbid=%3%, datas=%4%!\n") % pOrdersCharge->ordersID % pOrdersCharge->dbid % pOrdersCharge->cbid % pOrdersCharge->postDatas % pOrdersCharge->baseappID); ORDERS::iterator iter = orders_.find(pOrdersCharge->ordersID); if(iter != orders_.end()) { ERROR_MSG(boost::format("BillingSystem::charge: chargeID=%1% is exist!\n") % pOrdersCharge->ordersID); delete pOrdersCharge; return; } ChargeTask* pinfo = new ChargeTask(); pinfo->pOrders = pOrdersCharge; orders_[pOrdersCharge->ordersID].reset(pOrdersCharge); this->threadPool().addTask(pinfo); }
//------------------------------------------------------------------------------------- void BillingHandler_ThirdParty::charge(Network::Channel* pChannel, KBEngine::MemoryStream& s) { std::string chargeID; std::string datas; CALLBACK_ID cbid; DBID dbid; s >> chargeID; s >> dbid; s.readBlob(datas); s >> cbid; INFO_MSG(fmt::format("BillingHandler_ThirdParty::charge: chargeID={0}, dbid={3}, cbid={1}, datas={2}!\n", chargeID, cbid, datas, dbid)); KBE_ASSERT(pBillingChannel_); Network::Bundle::SmartPoolObjectPtr bundle = Network::Bundle::createSmartPoolObj(); (*(*bundle)).newMessage(BillingSystemInterface::charge); (*(*bundle)) << pChannel->componentID(); (*(*bundle)) << chargeID; (*(*bundle)) << dbid; (*(*bundle)).appendBlob(datas); (*(*bundle)) << cbid; if(pBillingChannel_->isDestroyed()) { if(!this->reconnect()) return; } (*(*bundle)).send(Dbmgr::getSingleton().networkInterface(), pBillingChannel_); }
//------------------------------------------------------------------------------------- void InterfacesHandler_Interfaces::charge(Network::Channel* pChannel, KBEngine::MemoryStream& s) { Network::Channel* pInterfacesChannel = Dbmgr::getSingleton().networkInterface().findChannel(g_kbeSrvConfig.interfacesAddr()); KBE_ASSERT(pInterfacesChannel); if(pInterfacesChannel->isDestroyed()) { if(!this->reconnect()) return; } std::string chargeID; std::string datas; CALLBACK_ID cbid; DBID dbid; s >> chargeID; s >> dbid; s.readBlob(datas); s >> cbid; INFO_MSG(fmt::format("InterfacesHandler_Interfaces::charge: chargeID={0}, dbid={3}, cbid={1}, datas={2}!\n", chargeID, cbid, datas, dbid)); Network::Bundle* pBundle = Network::Bundle::createPoolObject(); (*pBundle).newMessage(InterfacesInterface::charge); (*pBundle) << pChannel->componentID(); (*pBundle) << chargeID; (*pBundle) << dbid; (*pBundle).appendBlob(datas); (*pBundle) << cbid; pInterfacesChannel->send(pBundle); }
//------------------------------------------------------------------------------------- void InterfacesHandler_Interfaces::onChargeCB(KBEngine::MemoryStream& s) { std::string chargeID; std::string datas; CALLBACK_ID cbid; COMPONENT_ID cid; DBID dbid; SERVER_ERROR_CODE retcode; s >> cid; s >> chargeID; s >> dbid; s.readBlob(datas); s >> cbid; s >> retcode; INFO_MSG(fmt::format("InterfacesHandler_Interfaces::onChargeCB: chargeID={0}, dbid={3}, cbid={1}, cid={4}, datas={2}!\n", chargeID, cbid, datas, dbid, cid)); Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(BASEAPP_TYPE, cid); if (cid == 0 || cinfos == NULL || cinfos->pChannel == NULL || cinfos->pChannel->isDestroyed()) { ERROR_MSG(fmt::format("InterfacesHandler_Interfaces::onChargeCB: baseapp not found!, chargeID={}, cid={}.\n", chargeID, cid)); // 此时应该随机找一个baseapp调用onLoseChargeCB bool found = false; Components::COMPONENTS& components = Components::getSingleton().getComponents(BASEAPP_TYPE); for (Components::COMPONENTS::iterator iter = components.begin(); iter != components.end(); ++iter) { cinfos = &(*iter); if (cinfos == NULL || cinfos->pChannel == NULL || cinfos->pChannel->isDestroyed()) { continue; } WARNING_MSG(fmt::format("InterfacesHandler_Interfaces::onChargeCB: , chargeID={}, not found cid={}, forward to component({}) processing!\n", chargeID, cid, cinfos->cid)); found = true; break; } if (!found) return; } Network::Bundle* pBundle = Network::Bundle::createPoolObject(); (*pBundle).newMessage(BaseappInterface::onChargeCB); (*pBundle) << chargeID; (*pBundle) << dbid; (*pBundle).appendBlob(datas); (*pBundle) << cbid; (*pBundle) << retcode; cinfos->pChannel->send(pBundle); }
//------------------------------------------------------------------------------------- void Dbmgr::executeRawDatabaseCommand(Mercury::Channel* pChannel, KBEngine::MemoryStream& s) { dbThreadPool_.addTask(new DBTaskExecuteRawDatabaseCommand(pChannel->addr(), s)); s.opfini(); numExecuteRawDatabaseCommand_++; }
//------------------------------------------------------------------------------------- void Dbmgr::syncEntityStreamTemplate(Network::Channel* pChannel, KBEngine::MemoryStream& s) { int rpos = s.rpos(); EntityTables::ENTITY_TABLES_MAP::iterator iter = EntityTables::sEntityTables.begin(); for (; iter != EntityTables::sEntityTables.end(); ++iter) { KBEAccountTable* pTable = static_cast<KBEAccountTable*>(iter->second.findKBETable("kbe_accountinfos")); KBE_ASSERT(pTable); s.rpos(rpos); pTable->accountDefMemoryStream(s); } s.done(); }
//------------------------------------------------------------------------------------- void Dbmgr::executeRawDatabaseCommand(Network::Channel* pChannel, KBEngine::MemoryStream& s) { ENTITY_ID entityID = -1; s >> entityID; uint16 dbInterfaceIndex = 0; s >> dbInterfaceIndex; std::string dbInterfaceName = g_kbeSrvConfig.dbInterfaceIndex2dbInterfaceName(dbInterfaceIndex); if (dbInterfaceName.size() == 0) { ERROR_MSG(fmt::format("Dbmgr::executeRawDatabaseCommand: not found dbInterface({})!\n", dbInterfaceName)); s.done(); return; } if (entityID == -1) { thread::ThreadPool* pThreadPool = DBUtil::pThreadPool(dbInterfaceName); if (!pThreadPool) { ERROR_MSG(fmt::format("Dbmgr::executeRawDatabaseCommand: not found pThreadPool(dbInterface={})!\n", dbInterfaceName)); s.done(); return; } pThreadPool->addTask(new DBTaskExecuteRawDatabaseCommand(pChannel->addr(), s)); } else { Buffered_DBTasks* pBuffered_DBTasks = findBufferedDBTask(dbInterfaceName); if (!pBuffered_DBTasks) { ERROR_MSG(fmt::format("Dbmgr::executeRawDatabaseCommand: not found pBuffered_DBTasks(dbInterface={})!\n", dbInterfaceName)); s.done(); return; } pBuffered_DBTasks->addTask(new DBTaskExecuteRawDatabaseCommandByEntity(pChannel->addr(), s, entityID)); } s.done(); ++numExecuteRawDatabaseCommand_; }
//------------------------------------------------------------------------------------- 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 Cellapp::onExecuteRawDatabaseCommandCB(Mercury::Channel* pChannel, KBEngine::MemoryStream& s) { std::string err; CALLBACK_ID callbackID = 0; uint32 nrows = 0; uint32 nfields = 0; uint64 affectedRows = 0; PyObject* pResultSet = NULL; PyObject* pAffectedRows = NULL; PyObject* pErrorMsg = NULL; s >> callbackID; s >> err; if(err.size() <= 0) { s >> nfields; pErrorMsg = Py_None; Py_INCREF(pErrorMsg); if(nfields > 0) { pAffectedRows = Py_None; Py_INCREF(pAffectedRows); s >> nrows; pResultSet = PyList_New(nrows); for (uint32 i = 0; i < nrows; ++i) { PyObject* pRow = PyList_New(nfields); for(uint32 j = 0; j < nfields; ++j) { std::string cell; s.readBlob(cell); PyObject* pCell = NULL; if(cell == "NULL") { Py_INCREF(Py_None); pCell = Py_None; } else { pCell = PyBytes_FromStringAndSize(cell.data(), cell.length()); } PyList_SET_ITEM(pRow, j, pCell); } PyList_SET_ITEM(pResultSet, i, pRow); } }
//------------------------------------------------------------------------------------- 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 Logger::updateLogWatcherSetting(Network::Channel* pChannel, KBEngine::MemoryStream& s) { LogWatcher* pLogwatcher = &logWatchers_[pChannel->addr()]; if(!pLogwatcher->updateSetting(&s)) { ERROR_MSG(fmt::format("Logger::updateLogWatcherSetting: addr={} is failed!\n", pChannel->addr().c_str())); logWatchers_.erase(pChannel->addr()); } s.done(); }
//------------------------------------------------------------------------------------- void InterfacesHandler_Interfaces::onLoginAccountCB(KBEngine::MemoryStream& s) { std::string loginName, accountName, password, postdatas, getdatas; COMPONENT_ID cid; SERVER_ERROR_CODE success = SERVER_ERR_OP_FAILED; s >> cid >> loginName >> accountName >> password >> success; s.readBlob(postdatas); s.readBlob(getdatas); bool needCheckPassword = (success == SERVER_ERR_LOCAL_PROCESSING); if (success != SERVER_SUCCESS && success != SERVER_ERR_LOCAL_PROCESSING) accountName = ""; else success = SERVER_SUCCESS; Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(LOGINAPP_TYPE, cid); if(cinfos == NULL || cinfos->pChannel == NULL) { ERROR_MSG("InterfacesHandler_Interfaces::onLoginAccountCB: loginapp not found!\n"); return; } std::string dbInterfaceName = Dbmgr::getSingleton().selectAccountDBInterfaceName(accountName); thread::ThreadPool* pThreadPool = DBUtil::pThreadPool(dbInterfaceName); if (!pThreadPool) { ERROR_MSG(fmt::format("InterfacesHandler_Interfaces::onLoginAccountCB: not found dbInterface({})!\n", dbInterfaceName)); return; } pThreadPool->addTask(new DBTaskAccountLogin(cinfos->pChannel->addr(), loginName, accountName, password, success, postdatas, getdatas, needCheckPassword)); }
//------------------------------------------------------------------------------------- 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::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); }
inline void CallbackMgr<PyObjectPtr>::addToStream(KBEngine::MemoryStream& s) { uint32 size = cbMap_.size(); s << idAlloc_.lastID() << size; CALLBACKS::iterator iter = cbMap_.begin(); for(; iter != cbMap_.end(); iter++) { s << iter->first; s.appendBlob(script::Pickler::pickle(iter->second.first.get())); s << iter->second.second; } }
//------------------------------------------------------------------------------------- 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::reqCreateAccount(Mercury::Channel* pChannel, KBEngine::MemoryStream& s) { std::string registerName, password, datas; s >> registerName >> password; s.readBlob(datas); if(registerName.size() == 0) { ERROR_MSG("Dbmgr::reqCreateAccount: registerName is empty.\n"); return; } pBillingHandler_->createAccount(pChannel, registerName, password, datas); numCreatedAccount_++; }
//------------------------------------------------------------------------------------- void Dbmgr::executeRawDatabaseCommand(Network::Channel* pChannel, KBEngine::MemoryStream& s) { ENTITY_ID entityID = -1; s >> entityID; if(entityID == -1) DBUtil::pThreadPool()->addTask(new DBTaskExecuteRawDatabaseCommand(pChannel->addr(), s)); else bufferedDBTasks_.addTask(new DBTaskExecuteRawDatabaseCommandByEntity(pChannel->addr(), s, entityID)); s.done(); numExecuteRawDatabaseCommand_++; }
//------------------------------------------------------------------------------------- void InterfacesHandler_ThirdParty::onCreateAccountCB(KBEngine::MemoryStream& s) { std::string registerName, accountName, password, postdatas, getdatas; COMPONENT_ID cid; SERVER_ERROR_CODE success = SERVER_ERR_OP_FAILED; s >> cid >> registerName >> accountName >> password >> success; s.readBlob(postdatas); s.readBlob(getdatas); if(success != SERVER_SUCCESS) { accountName = ""; } Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(LOGINAPP_TYPE, cid); if(cinfos == NULL || cinfos->pChannel == NULL) { ERROR_MSG("InterfacesHandler_ThirdParty::onCreateAccountCB: loginapp not found!\n"); return; } std::string dbInterfaceName = Dbmgr::getSingleton().selectAccountDBInterfaceName(accountName); thread::ThreadPool* pThreadPool = DBUtil::pThreadPool(dbInterfaceName); if (!pThreadPool) { ERROR_MSG(fmt::format("InterfacesHandler_ThirdParty::onCreateAccountCB: not found dbInterface({})!\n", dbInterfaceName)); return; } pThreadPool->addTask(new DBTaskCreateAccount(cinfos->pChannel->addr(), registerName, accountName, password, postdatas, getdatas)); }
//------------------------------------------------------------------------------------- void ClientObjectBase::onRemoteMethodCall(Mercury::Channel * pChannel, KBEngine::MemoryStream& s) { ENTITY_ID eid; s >> eid; client::Entity* entity = pEntities_->find(eid); if(entity == NULL) { s.opfini(); ERROR_MSG(boost::format("ClientObjectBase::onRemoteMethodCall: not found entity(%1%).\n") % eid); return; } entity->onRemoteMethodCall(this->pServerChannel(), s); }
//------------------------------------------------------------------------------------- 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 Interfaces::reqCreateAccount(Network::Channel* pChannel, KBEngine::MemoryStream& s) { std::string registerName, accountName, password, datas; COMPONENT_ID cid; uint8 accountType = 0; s >> cid >> registerName >> password >> accountType; s.readBlob(datas); if(accountType == (uint8)ACCOUNT_TYPE_MAIL) { } REQCREATE_MAP::iterator iter = reqCreateAccount_requests_.find(registerName); if(iter != reqCreateAccount_requests_.end()) { return; } CreateAccountTask* pinfo = new CreateAccountTask(); pinfo->commitName = registerName; pinfo->accountName = registerName; pinfo->getDatas = ""; pinfo->password = password; pinfo->postDatas = datas; pinfo->retcode = SERVER_ERR_OP_FAILED; pinfo->baseappID = cid; pinfo->dbmgrID = pChannel->componentID(); pinfo->address = pChannel->addr(); pinfo->enable = true; reqCreateAccount_requests_[pinfo->commitName] = pinfo; // 把请求交由脚本处理 SCOPED_PROFILE(SCRIPTCALL_PROFILE); PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(), const_cast<char*>("onRequestCreateAccount"), const_cast<char*>("ssy#"), registerName.c_str(), password.c_str(), datas.c_str(), datas.length()); if(pyResult != NULL) Py_DECREF(pyResult); else SCRIPT_ERROR_CHECK(); }
//------------------------------------------------------------------------------------- void Dbmgr::reqCreateAccount(Network::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; } pInterfacesAccountHandler_->createAccount(pChannel, registerName, password, datas, ACCOUNT_TYPE(uatype)); numCreatedAccount_++; }