当前位置: 首页>>代码示例>>C++>>正文


C++ mercury::Bundle类代码示例

本文整理汇总了C++中mercury::Bundle的典型用法代码示例。如果您正苦于以下问题:C++ Bundle类的具体用法?C++ Bundle怎么用?C++ Bundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Bundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:afreetgo,项目名称:kbengine,代码行数:33,代码来源:loginapp.cpp

示例2: onMessage

//-------------------------------------------------------------------------------------
void DebugHelper::onMessage(uint32 logType, const char * str, uint32 length)
{
    if(g_componentType == MACHINE_TYPE ||
            g_componentType == CONSOLE_TYPE || g_componentType == MESSAGELOG_TYPE)
        return;

    if(length <= 0)
        return;

    Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();

    int8 v = Mercury::g_trace_packet;
    Mercury::g_trace_packet = 0;
    pBundle->newMessage(MessagelogInterface::writeLog);

    (*pBundle) << logType;
    (*pBundle) << g_componentType;
    (*pBundle) << g_componentID;
    (*pBundle) << g_componentOrder;

    int64 t = time(NULL);
    (*pBundle) << t;
    (*pBundle) << g_kbetime;
    (*pBundle) << str;

    bufferedLogPackets_.push_back(pBundle);

    Mercury::g_trace_packet = v;
    if(!syncStarting_)
    {
        if(pDispatcher_)
            pDispatcher_->addFrequentTask(this);
        syncStarting_ = true;
    }
}
开发者ID:sdsgwangpeng,项目名称:kbengine,代码行数:36,代码来源:debug_helper.cpp

示例3: 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);
}
开发者ID:KitoHo,项目名称:kbengine,代码行数:31,代码来源:serverapp.cpp

示例4: 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);
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例5: newMail

//-------------------------------------------------------------------------------------
void EntityMailboxAbstract::newMail(Mercury::Bundle& bundle)
{
	if(componentID_ == 0)	// 客户端
	{
		bundle.newMessage(ClientInterface::onRemoteMethodCall);
	}
	else					// 服务器组件
	{
		Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(componentID_);

		if(cinfos != NULL)
		{
			// 找到对应的组件投递过去, 如果这个mailbox还需要中转比如 e.base.cell , 则由baseapp转往cellapp
			if(cinfos->componentType == BASEAPP_TYPE)
			{
				bundle.newMessage(BaseappInterface::onEntityMail);
			}
			else
			{
				bundle.newMessage(CellappInterface::onEntityMail);
			}
		}
		else
		{
			ERROR_MSG("EntityMailboxAbstract::newMail: not found component!\n");
		}
	}

	bundle << id_;
	
	// 如果是发往客户端的包则无需附加这样一个类型
	if(componentID_ > 0)
		bundle << type_;
}
开发者ID:guozanhua,项目名称:kbengine,代码行数:35,代码来源:entitymailboxabstract.cpp

示例6: 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");
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例7: onDefDataChanged

//-------------------------------------------------------------------------------------
void Proxy::onDefDataChanged(const PropertyDescription* propertyDescription, 
		PyObject* pyData)
{
	uint32 flags = propertyDescription->getFlags();

	if((flags & ED_FLAG_BASE_AND_CLIENT) <= 0 || clientMailbox_ == NULL)
		return;

	// 创建一个需要广播的模板流
	MemoryStream* mstream = MemoryStream::ObjPool().createObject();

	propertyDescription->getDataType()->addToStream(mstream, pyData);

	Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
	(*pBundle).newMessage(ClientInterface::onUpdatePropertys);
	(*pBundle) << id();

	if(scriptModule_->usePropertyDescrAlias())
		(*pBundle) << propertyDescription->aliasIDAsUint8();
	else
		(*pBundle) << propertyDescription->getUType();

	pBundle->append(*mstream);
	
	g_privateClientEventHistoryStats.trackEvent(scriptName(), 
		propertyDescription->getName(), 
		pBundle->currMsgLength());

	sendToClient(ClientInterface::onUpdatePropertys, pBundle);
	MemoryStream::ObjPool().reclaimObject(mstream);
}
开发者ID:,项目名称:,代码行数:32,代码来源:

示例8: 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);
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例9: 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);
}
开发者ID:afreetgo,项目名称:kbengine,代码行数:32,代码来源:loginapp.cpp

示例10: 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);
}
开发者ID:MapleEve,项目名称:kbengine,代码行数:34,代码来源:telnet_handler.cpp

示例11: sync

//-------------------------------------------------------------------------------------
void DebugHelper::sync()
{
	lockthread();

	if(hasBufferedLogPackets_ == 0)
	{
		unlockthread();
		return;
	}

	if(Mercury::Address::NONE == messagelogAddr_)
	{
		if(hasBufferedLogPackets_ > g_kbeSrvConfig.tickMaxBufferedLogs())
		{
			clearBufferedLog();
		}
		
		canLogFile_ = true;
		unlockthread();
		return;
	}
	
	Mercury::Channel* pMessagelogChannel = pNetworkInterface_->findChannel(messagelogAddr_);
	if(pMessagelogChannel == NULL)
	{
		if(hasBufferedLogPackets_ > g_kbeSrvConfig.tickMaxBufferedLogs())
		{
			clearBufferedLog();
		}
		
		canLogFile_ = true;
		unlockthread();
		return;
	}

	int8 v = Mercury::g_trace_packet;
	Mercury::g_trace_packet = 0;

	uint32 i = 0;
	size_t totalLen = 0;

	while(!bufferedLogPackets_.empty())
	{
		if(i++ >= g_kbeSrvConfig.tickMaxSyncLogs() || totalLen > (PACKET_MAX_SIZE_TCP * 10))
			break;
		
		Mercury::Bundle* pBundle = bufferedLogPackets_.front();
		bufferedLogPackets_.pop();

		totalLen += pBundle->currMsgLength();
		pMessagelogChannel->send(pBundle);
		
		--hasBufferedLogPackets_;
	}

	Mercury::g_trace_packet = v;
	canLogFile_ = false;
	unlockthread();
}
开发者ID:KitoHo,项目名称:kbengine,代码行数:60,代码来源:debug_helper.cpp

示例12: newMail

//-------------------------------------------------------------------------------------
void EntityMailboxAbstract::newMail(Mercury::Bundle& bundle)
{
	// 如果是server端的mailbox
	if(g_componentType != CLIENT_TYPE && g_componentType != BOTS_TYPE)
	{
		if(componentID_ == 0)	// 客户端
		{
			bundle.newMessage(ClientInterface::onRemoteMethodCall);
		}
		else					// 服务器组件
		{
			Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(componentID_);

			if(cinfos != NULL)
			{
				// 找到对应的组件投递过去, 如果这个mailbox还需要中转比如 e.base.cell , 则由baseapp转往cellapp
				if(cinfos->componentType == BASEAPP_TYPE)
				{
					bundle.newMessage(BaseappInterface::onEntityMail);
				}
				else
				{
					bundle.newMessage(CellappInterface::onEntityMail);
				}
			}
			else
			{
				ERROR_MSG(fmt::format("EntityMailboxAbstract::newMail: not found component({})!\n",
					componentID_));
			}
		}

		bundle << id_;
		
		// 如果是发往客户端的包则无需附加这样一个类型
		if(componentID_ > 0)
			bundle << type_;
	}
	else
	{
		// 如果是客户端上的mailbox调用服务端方法只存在调用cell或者base
		switch(type_)
		{
		case MAILBOX_TYPE_BASE:
			bundle.newMessage(BaseappInterface::onRemoteMethodCall);
			break;
		case MAILBOX_TYPE_CELL:
			bundle.newMessage(BaseappInterface::onRemoteCallCellMethodFromClient);
			break;
		default:
			KBE_ASSERT(false && "no support!\n");
			break;
		};

		bundle << id_;
	}
}
开发者ID:321543223,项目名称:kbengine,代码行数:58,代码来源:entitymailboxabstract.cpp

示例13: onClientEntityEnterWorld

//-------------------------------------------------------------------------------------
void Baseapp::onClientEntityEnterWorld(Proxy* base)
{
	base->initClientCellPropertys();

	Mercury::Bundle bundle;
	bundle.newMessage(ClientInterface::onEntityEnterWorld);
	bundle << base->getID();
	bundle << base->getSpaceID();
	base->getClientMailbox()->postMail(bundle);
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例14: loginGateWay

//-------------------------------------------------------------------------------------
bool ClientObject::loginGateWay()
{
	// 请求登录网关
	Mercury::Bundle bundle;
	bundle.newMessage(BaseappInterface::loginGateway);
	bundle << name_;
	bundle << password_;
	bundle.send(*pChannel_->endpoint());
	return true;
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例15: createAccount

//-------------------------------------------------------------------------------------
bool ClientObject::createAccount()
{
	// 创建账号
	Mercury::Bundle bundle;
	bundle.newMessage(LoginappInterface::reqCreateAccount);
	bundle << name_;
	bundle << password_;
	bundle.send(*pChannel_->endpoint());
	return true;
}
开发者ID:,项目名称:,代码行数:11,代码来源:


注:本文中的mercury::Bundle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。