本文整理汇总了C++中kbengine::MemoryStream::readBlob方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryStream::readBlob方法的具体用法?C++ MemoryStream::readBlob怎么用?C++ MemoryStream::readBlob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kbengine::MemoryStream
的用法示例。
在下文中一共展示了MemoryStream::readBlob方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onLoginAccountCB
//-------------------------------------------------------------------------------------
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));
}
示例2: charge
//-------------------------------------------------------------------------------------
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);
}
示例3: onAccountLogin
//-------------------------------------------------------------------------------------
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);
}
示例4: onExecScriptCommand
//-------------------------------------------------------------------------------------
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);
}
示例5: charge
//-------------------------------------------------------------------------------------
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_);
}
示例6: onChargeCB
//-------------------------------------------------------------------------------------
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);
}
示例7: onBroadcastGlobalDataChanged
//-------------------------------------------------------------------------------------
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;
};
}
示例8: onExecuteRawDatabaseCommandCB
//-------------------------------------------------------------------------------------
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);
}
}
示例9: onLoginAccountCB
//-------------------------------------------------------------------------------------
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));
}
示例10: onAccountLogin
//-------------------------------------------------------------------------------------
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);
}
示例11: onCreateAccountCB
//-------------------------------------------------------------------------------------
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));
}
示例12: reqCreateAccount
//-------------------------------------------------------------------------------------
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_++;
}
示例13: reqCreateAccount
//-------------------------------------------------------------------------------------
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();
}
示例14: reqCreateAccount
//-------------------------------------------------------------------------------------
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_++;
}
示例15: charge
//-------------------------------------------------------------------------------------
void Interfaces::charge(Network::Channel* pChannel, KBEngine::MemoryStream& s)
{
OrdersCharge* pOrdersCharge = new OrdersCharge();
pOrdersCharge->timeout = timestamp() + uint64(g_kbeSrvConfig.interfaces_orders_timeout_ * stampsPerSecond());
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(fmt::format("Interfaces::charge: componentID={4}, chargeID={0}, dbid={1}, cbid={2}, datas={3}!\n",
pOrdersCharge->ordersID, pOrdersCharge->dbid, pOrdersCharge->cbid, pOrdersCharge->postDatas, pOrdersCharge->baseappID));
ORDERS::iterator iter = orders_.find(pOrdersCharge->ordersID);
if(iter != orders_.end())
{
ERROR_MSG(fmt::format("Interfaces::charge: chargeID={} is exist!\n", pOrdersCharge->ordersID));
delete pOrdersCharge;
return;
}
ChargeTask* pinfo = new ChargeTask();
pinfo->orders = *pOrdersCharge;
pinfo->pOrders = pOrdersCharge;
orders_[pOrdersCharge->ordersID].reset(pOrdersCharge);
// 把请求交由脚本处理
SCOPED_PROFILE(SCRIPTCALL_PROFILE);
PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(),
const_cast<char*>("onRequestCharge"),
const_cast<char*>("sKy#"),
pOrdersCharge->ordersID.c_str(),
pOrdersCharge->dbid,
pOrdersCharge->postDatas.c_str(), pOrdersCharge->postDatas.length());
if(pyResult != NULL)
Py_DECREF(pyResult);
else
SCRIPT_ERROR_CHECK();
}