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


C++ Bundle::newMessage方法代码示例

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


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

示例1: newMail

//-------------------------------------------------------------------------------------
void EntityMailboxAbstract::newMail(Network::Bundle& bundle)
{
	// If it is a server-side mailbox
	if(g_componentType != CLIENT_TYPE && g_componentType != BOTS_TYPE)
	{
		// If the ID is 0, then this is a client-side component, otherwise the server-side.
		if(componentID_ == 0)
		{
			bundle.newMessage(ClientInterface::onRemoteMethodCall);
		}
		else
		{
			Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(componentID_);

			if(cinfos != NULL)
			{
				// Post a component found in the past, if the mailbox needs to transit such as e.base.cell, by baseapp transferred 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({}), entityID({})!\n",
					componentID_, id_));
			}
		}

		bundle << id_;
		
		// If the package is sent to the client is not necessary to attach such a type
		if(componentID_ > 0)
			bundle << type_;
	}
	else
	{
		// If the mailbox is on the client calls the server-side method calls the cell or 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:Orav,项目名称:kbengine,代码行数:59,代码来源:entitymailboxabstract.cpp

示例2: newMail

//-------------------------------------------------------------------------------------
void EntityMailboxAbstract::newMail(Network::Bundle& bundle)
{
    // 如果是server端的mailbox
    if(g_componentType != CLIENT_TYPE && g_componentType != BOTS_TYPE)
    {
        // 如果ID为0,则这是一个客户端组件,否则为服务端。
        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:ArcherPeng,项目名称:kbengine-cocos2dx,代码行数:59,代码来源:entitymailboxabstract.cpp

示例3: onClientActiveTick

//-------------------------------------------------------------------------------------
void Loginapp::onClientActiveTick(Network::Channel* pChannel)
{
	if(!pChannel->isExternal())
		return;

	onAppActiveTick(pChannel, CLIENT_TYPE, 0);

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();
	pBundle->newMessage(ClientInterface::onAppActiveTickCB);
	pChannel->send(pBundle);
}
开发者ID:hyperfact,项目名称:kbengine,代码行数:12,代码来源:loginapp.cpp

示例4: onMessage

//-------------------------------------------------------------------------------------
void LogWatcher::onMessage(uint32 logtype, COMPONENT_TYPE componentType, COMPONENT_ID componentID, COMPONENT_ORDER componentOrder, 
	int64 tm, GAME_TIME kbetime, const std::string& str, const std::stringstream& sstr)
{
	if(!VALID_COMPONENT(componentType) || componentBitmap_[componentType] == 0)
		return;

	if((logtypes_ & logtype) <= 0)
		return;

	if(appOrder_ > 0 && appOrder_ != componentOrder)
		return;


	Network::Channel* pChannel = Messagelog::getSingleton().networkInterface().findChannel(addr_);

	if(pChannel == NULL)
		return;

	Network::Bundle bundle;
	ConsoleInterface::ConsoleLogMessageHandler msgHandler;
	bundle.newMessage(msgHandler);
	bundle << sstr.str().c_str();
	bundle.send(Messagelog::getSingleton().networkInterface(), pChannel);
}
开发者ID:mengdizhang,项目名称:kbengine,代码行数:25,代码来源:logwatcher.cpp

示例5: proxy

//-------------------------------------------------------------------------------------
thread::TPTask::TPTaskState DataDownload::presentMainThread()
{
	if(error_)
	{
		ERROR_MSG(fmt::format("DataDownload::presentMainThread: proxy({}), downloadID({}), type({}), thread error.\n", 
			entityID(), id(), type()));

		return thread::TPTask::TPTASK_STATE_COMPLETED; 
	}

	uint32 datasize = GAME_PACKET_MAX_SIZE_TCP - sizeof(int16) - sizeof(uint32);

	if(remainSent_ > 0 && currSent_ < remainSent_)
	{
		Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();

		if(!sentStart_)
		{
			pBundle->newMessage(ClientInterface::onStreamDataStarted);
			(*pBundle) << this->id();
			(*pBundle) << totalBytes_;
			(*pBundle) << descr_;
			(*pBundle) << type();

			sentStart_ = true;
			if(!send(ClientInterface::onStreamDataStarted, pBundle))
			{
				DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({}), downloadID({}), type({}), thread exit.\n",
					entityID(), id(), type()));

				return thread::TPTask::TPTASK_STATE_COMPLETED; 
			}

			return thread::TPTask::TPTASK_STATE_CONTINUE_MAINTHREAD; 
		}

		pBundle->newMessage(ClientInterface::onStreamDataRecv);
		(*pBundle) << id();

		if(remainSent_ - currSent_ > datasize)
		{
			(*pBundle) << datasize;
			(*pBundle).append(getOutStream() + currSent_, datasize);

			currSent_ += datasize;
			totalSentBytes_ += datasize;

			if(!send(ClientInterface::onStreamDataRecv, pBundle))
			{
				DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({}), downloadID({}), type({}), thread exit.\n",
					entityID(), id(), type()));

				error_ = true;
				return thread::TPTask::TPTASK_STATE_COMPLETED; 
			}
		}
		else
		{
			datasize = remainSent_ - currSent_;
			(*pBundle) << datasize;
			(*pBundle).append(getOutStream() + currSent_, datasize);

			if(!send(ClientInterface::onStreamDataRecv, pBundle))
			{
				DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({}), downloadID({}), type({}), thread exit.\n",
					entityID(), id(), type()));

				error_ = true;
				return thread::TPTask::TPTASK_STATE_COMPLETED; 
			}

			totalSentBytes_ += datasize;
			currSent_ = remainSent_;
		}
	}

	if(totalSentBytes_ == totalBytes_)
	{
		DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({0}), downloadID({1}), type({6}), sentBytes={5},{2}/{3} ({4:.2f}%).\n",
			entityID(), id(), totalSentBytes_, this->totalBytes(), 100.0f, datasize, type()));

		pDataDownloads_->onDownloadCompleted(this);

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


		pBundle->newMessage(ClientInterface::onStreamDataCompleted);
		(*pBundle) << this->id();

		send(ClientInterface::onStreamDataCompleted, pBundle);
		return thread::TPTask::TPTASK_STATE_COMPLETED; 
	}
	
	DEBUG_MSG(fmt::format("DataDownload::presentMainThread: proxy({0}), downloadID({1}), type({6}), sentBytes={5},{2}/{3} ({4:.2f}%).\n",
		entityID(), id(), totalSentBytes_, this->totalBytes(), 
		(((float)totalSentBytes_ / (float)this->totalBytes()) * 100.0f), datasize, type()));

	if(currSent_ == remainSent_)
	{
//.........这里部分代码省略.........
开发者ID:lmb0989,项目名称:kbengine,代码行数:101,代码来源:data_download.cpp


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