本文整理汇总了C++中kbengine::MemoryStream类的典型用法代码示例。如果您正苦于以下问题:C++ MemoryStream类的具体用法?C++ MemoryStream怎么用?C++ MemoryStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MemoryStream类的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: 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);
}
示例3: onReceiveWatcherData
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);
};
}
示例4: 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);
}
示例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: 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);
}
示例7: 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);
}
示例8: executeRawDatabaseCommand
//-------------------------------------------------------------------------------------
void Dbmgr::executeRawDatabaseCommand(Mercury::Channel* pChannel,
KBEngine::MemoryStream& s)
{
dbThreadPool_.addTask(new DBTaskExecuteRawDatabaseCommand(pChannel->addr(), s));
s.opfini();
numExecuteRawDatabaseCommand_++;
}
示例9: 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;
};
}
示例10: 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);
}
}
示例11: syncEntityStreamTemplate
//-------------------------------------------------------------------------------------
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();
}
示例12: updateLogWatcherSetting
//-------------------------------------------------------------------------------------
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();
}
示例13: 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));
}
示例14: writeEntity
//-------------------------------------------------------------------------------------
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_++;
}
示例15: 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);
}