本文整理汇总了C++中mercury::Bundle::send方法的典型用法代码示例。如果您正苦于以下问题:C++ Bundle::send方法的具体用法?C++ Bundle::send怎么用?C++ Bundle::send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mercury::Bundle
的用法示例。
在下文中一共展示了Bundle::send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createInNewSpace
//-------------------------------------------------------------------------------------
void Baseapp::createInNewSpace(Base* base, PyObject* cell)
{
ENTITY_ID id = base->getID();
std::string entityType = base->ob_type->tp_name;
std::string strCellData = script::Pickler::pickle(base->getCellData());
uint32 cellDataLength = strCellData.length();
Mercury::Bundle bundle;
bundle.newMessage(CellappmgrInterface::reqCreateInNewSpace);
bundle << entityType;
bundle << id;
bundle << componentID_;
bundle << cellDataLength;
if(cellDataLength > 0)
bundle.append(strCellData.data(), cellDataLength);
Components::COMPONENTS& components = Components::getSingleton().getComponents(CELLAPPMGR_TYPE);
Components::COMPONENTS::iterator iter = components.begin();
if(iter != components.end())
{
bundle.send(this->getNetworkInterface(), (*iter).pChannel);
return;
}
ERROR_MSG("Baseapp::createInNewSpace: not found cellappmgr.\n");
}
示例2: onChannelDeregister
//-------------------------------------------------------------------------------------
void Loginapp::onChannelDeregister(Mercury::Channel * pChannel)
{
// 如果是外部通道则处理
if(!pChannel->isInternal())
{
const std::string& extra = pChannel->extra();
// 通知billing从队列中清除他的请求, 避免拥塞
if(extra.size() > 0)
{
Components::COMPONENTS& cts = Components::getSingleton().getComponents(DBMGR_TYPE);
Components::ComponentInfos* dbmgrinfos = NULL;
if(cts.size() > 0)
dbmgrinfos = &(*cts.begin());
if(dbmgrinfos == NULL || dbmgrinfos->pChannel == NULL || dbmgrinfos->cid == 0)
{
}
else
{
Mercury::Bundle bundle;
bundle.newMessage(DbmgrInterface::eraseClientReq);
bundle << extra;
bundle.send(this->getNetworkInterface(), dbmgrinfos->pChannel);
}
}
}
ServerApp::onChannelDeregister(pChannel);
}
示例3: onReqCreateAccountResult
//-------------------------------------------------------------------------------------
void Loginapp::onReqCreateAccountResult(Mercury::Channel* pChannel, MemoryStream& s)
{
SERVER_ERROR_CODE failedcode;
std::string accountName;
std::string password;
std::string retdatas = "";
s >> failedcode >> accountName >> password;
s.readBlob(retdatas);
DEBUG_MSG(boost::format("Loginapp::onReqCreateAccountResult: accountName=%1%, failedcode=%2%.\n") %
accountName.c_str() % failedcode);
PendingLoginMgr::PLInfos* ptinfos = pendingCreateMgr_.remove(accountName);
if(ptinfos == NULL)
return;
Mercury::Channel* pClientChannel = this->getNetworkInterface().findChannel(ptinfos->addr);
if(pClientChannel == NULL)
return;
pClientChannel->extra("");
Mercury::Bundle bundle;
bundle.newMessage(ClientInterface::onCreateAccountResult);
bundle << failedcode;
bundle.appendBlob(retdatas);
bundle.send(this->getNetworkInterface(), pClientChannel);
SAFE_RELEASE(ptinfos);
}
示例4: queryWatcher
//-------------------------------------------------------------------------------------
void ServerApp::queryWatcher(Mercury::Channel* pChannel, MemoryStream& s)
{
AUTO_SCOPED_PROFILE("watchers");
std::string path;
s >> path;
MemoryStream::SmartPoolObjectPtr readStreamPtr = MemoryStream::createSmartPoolObj();
WatcherPaths::root().readWatchers(path, readStreamPtr.get()->get());
MemoryStream::SmartPoolObjectPtr readStreamPtr1 = MemoryStream::createSmartPoolObj();
WatcherPaths::root().readChildPaths(path, path, readStreamPtr1.get()->get());
Mercury::Bundle bundle;
ConsoleInterface::ConsoleWatcherCBMessageHandler msgHandler;
bundle.newMessage(msgHandler);
uint8 type = 0;
bundle << type;
bundle.append(readStreamPtr.get()->get());
bundle.send(getNetworkInterface(), pChannel);
Mercury::Bundle bundle1;
bundle1.newMessage(msgHandler);
type = 1;
bundle1 << type;
bundle1.append(readStreamPtr1.get()->get());
bundle1.send(getNetworkInterface(), pChannel);
}
示例5: reqTeleportOther
//-------------------------------------------------------------------------------------
void Base::reqTeleportOther(Mercury::Channel* pChannel, ENTITY_ID reqTeleportEntityID,
COMPONENT_ID reqTeleportEntityCellAppID, COMPONENT_ID reqTeleportEntityBaseAppID)
{
DEBUG_MSG("Base::reqTeleportOther: reqTeleportEntityID=%d, reqTeleportEntityCellAppID=%"PRAppID".\n",
reqTeleportEntityID, reqTeleportEntityCellAppID);
if(this->getCellMailbox() == NULL || this->getCellMailbox()->getChannel() == NULL)
{
ERROR_MSG("%s::reqTeleportOther: %d, teleport is error, cellMailbox is NULL, reqTeleportEntityID, reqTeleportEntityCellAppID=%"PRAppID".\n",
this->getScriptName(), this->getID(), reqTeleportEntityID, reqTeleportEntityCellAppID);
return;
}
Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(reqTeleportEntityCellAppID);
if(cinfos == NULL || cinfos->pChannel == NULL)
{
ERROR_MSG("%s::reqTeleportOther: %d, teleport is error, not found cellapp, reqTeleportEntityID, reqTeleportEntityCellAppID=%"PRAppID".\n",
this->getScriptName(), this->getID(), reqTeleportEntityID, reqTeleportEntityCellAppID);
return;
}
Mercury::Bundle bundle;
bundle.newMessage(CellappInterface::teleportFromBaseapp);
bundle << reqTeleportEntityID;
CellappInterface::teleportFromBaseappArgs3::staticAddToBundle(bundle, this->getCellMailbox()->getComponentID(), this->getID(), reqTeleportEntityBaseAppID);
bundle.send(Baseapp::getSingleton().getNetworkInterface(), cinfos->pChannel);
}
示例6: size
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);
}
示例7: processPythonCommand
//-------------------------------------------------------------------------------------
void TelnetHandler::processPythonCommand(std::string command)
{
if(pTelnetServer_->pScript() == NULL || command.size() == 0)
return;
command += "\n";
PyObject* pycmd = PyUnicode_DecodeUTF8(command.data(), command.size(), NULL);
if(pycmd == NULL)
{
SCRIPT_ERROR_CHECK();
return;
}
DEBUG_MSG(boost::format("TelnetHandler::processPythonCommand: size(%1%), command=%2%.\n") %
command.size() % command);
std::string retbuf = "";
PyObject* pycmd1 = PyUnicode_AsEncodedString(pycmd, "utf-8", NULL);
pTelnetServer_->pScript()->run_simpleString(PyBytes_AsString(pycmd1), &retbuf);
if(retbuf.size() > 0)
{
// 将结果返回给客户端
Mercury::Bundle bundle;
bundle << retbuf;
bundle.send(*pEndPoint_);
sendEnter();
}
Py_DECREF(pycmd);
Py_DECREF(pycmd1);
}
示例8: loginGateWay
//-------------------------------------------------------------------------------------
bool ClientObject::loginGateWay()
{
// 请求登录网关
Mercury::Bundle bundle;
bundle.newMessage(BaseappInterface::loginGateway);
bundle << name_;
bundle << password_;
bundle.send(*pChannel_->endpoint());
return true;
}
示例9: createAccount
//-------------------------------------------------------------------------------------
bool ClientObject::createAccount()
{
// 创建账号
Mercury::Bundle bundle;
bundle.newMessage(LoginappInterface::reqCreateAccount);
bundle << name_;
bundle << password_;
bundle.send(*pChannel_->endpoint());
return true;
}
示例10: reqAccountResetPassword
//-------------------------------------------------------------------------------------
void Loginapp::reqAccountResetPassword(Mercury::Channel* pChannel, std::string& accountName)
{
AUTO_SCOPED_PROFILE("reqAccountResetPassword");
accountName = KBEngine::strutil::kbe_trim(accountName);
INFO_MSG(boost::format("Loginapp::reqAccountResetPassword: accountName(%1%)\n") %
accountName);
Components::COMPONENTS& cts = Components::getSingleton().getComponents(DBMGR_TYPE);
Components::ComponentInfos* dbmgrinfos = NULL;
if(cts.size() > 0)
dbmgrinfos = &(*cts.begin());
if(dbmgrinfos == NULL || dbmgrinfos->pChannel == NULL || dbmgrinfos->cid == 0)
{
ERROR_MSG(boost::format("Loginapp::_createAccount: create(%1%), not found dbmgr!\n") %
accountName);
Mercury::Bundle bundle;
bundle.newMessage(ClientInterface::onReqAccountResetPasswordCB);
SERVER_ERROR_CODE retcode = SERVER_ERR_SRV_NO_READY;
bundle << retcode;
bundle.send(this->getNetworkInterface(), pChannel);
return;
}
{
Mercury::Bundle bundle;
bundle.newMessage(DbmgrInterface::accountReqResetPassword);
bundle << accountName;
bundle.send(this->getNetworkInterface(), dbmgrinfos->pChannel);
}
{
Mercury::Bundle bundle;
bundle.newMessage(ClientInterface::onReqAccountResetPasswordCB);
SERVER_ERROR_CODE retcode = SERVER_SUCCESS;
bundle << retcode;
bundle.send(this->getNetworkInterface(), pChannel);
}
}
示例11: forwardMessage
//-------------------------------------------------------------------------------------
void Cellappmgr::forwardMessage(Mercury::Channel* pChannel, MemoryStream& s)
{
COMPONENT_ID sender_componentID, forward_componentID;
s >> sender_componentID >> forward_componentID;
Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(forward_componentID);
KBE_ASSERT(cinfos != NULL && cinfos->pChannel != NULL);
Mercury::Bundle bundle;
bundle.append((char*)s.data() + s.rpos(), s.opsize());
bundle.send(this->getNetworkInterface(), cinfos->pChannel);
s.opfini();
}
示例12: size
void EntityApp<E>::onExecScriptCommand(Mercury::Channel* pChannel, std::string& strcommand)
{
DEBUG_MSG("EntityApp::onExecScriptCommand: command size(%d).\n", strcommand.size());
std::string retbuf = "";
if(script_.run_simpleString(strcommand, &retbuf) == 0)
{
// 将结果返回给客户端
Mercury::Bundle bundle;
ConsoleInterface::ConsoleExecCommandCBMessageHandler msgHandler;
bundle.newMessage(msgHandler);
ConsoleInterface::ConsoleExecCommandCBMessageHandlerArgs1::staticAddToBundle(bundle, retbuf);
bundle.send(this->getNetworkInterface(), pChannel);
}
}
示例13: getSelLogTypes
void CLogWindow::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
// 请求服务器拉取日志
CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
HTREEITEM item = dlg->hasCheckApp(MESSAGELOG_TYPE);
if(item == NULL)
{
::AfxMessageBox(L"messagelog no select!");
return;
}
Mercury::Address addr = dlg->getTreeItemAddr(item);
Mercury::Channel* pChannel = dlg->networkInterface().findChannel(addr);
if(pChannel == NULL)
{
::AfxMessageBox(L"messagelog is error!");
return;
}
Mercury::Bundle bundle;
bundle.newMessage(MessagelogInterface::registerLogWatcher);
bundle << getSelLogTypes();
CString apporder;
m_appIDEdit.GetWindowTextW(apporder);
char* cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
COMPONENT_ORDER order = atoi(cs);
free(cs);
bundle << order;
int8 count = 0;
std::vector<KBEngine::COMPONENT_TYPE> vec = getSelComponents();
count = vec.size();
bundle << count;
std::vector<KBEngine::COMPONENT_TYPE>::iterator iter = vec.begin();
for(; iter != vec.end(); iter++)
{
bundle << (*iter);
}
bundle.send(dlg->networkInterface(), pChannel);
}
示例14: destroyCellEntity
//-------------------------------------------------------------------------------------
bool Base::destroyCellEntity(void)
{
if(isDestroyed())
{
return false;
}
if(cellMailbox_ == NULL || cellMailbox_->getChannel() == NULL)
return false;
Mercury::Bundle bundle;
bundle.newMessage(CellappInterface::onDestroyCellEntityFromBaseapp);
bundle << id_;
bundle.send(Baseapp::getSingleton().getNetworkInterface(), cellMailbox_->getChannel());
return true;
}
示例15: sendTick
//-------------------------------------------------------------------------------------
void ClientObject::sendTick()
{
// 向服务器发送tick
uint64 check = uint64( Mercury::g_channelExternalTimeout * stampsPerSecond() ) / 2;
if (timestamp() - lastSentActiveTickTime_ > check)
{
lastSentActiveTickTime_ = timestamp();
Mercury::Bundle bundle;
if(connectedGateway_)
bundle.newMessage(BaseappInterface::onClientActiveTick);
else
bundle.newMessage(LoginappInterface::onClientActiveTick);
bundle.send(*pChannel_->endpoint());
}
}