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


C++ Channel::endpoint方法代码示例

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


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

示例1: onDataChanged

//-------------------------------------------------------------------------------------
void GlobalDataClient::onDataChanged(std::string& key, std::string& value, bool isDelete)
{
    Components::COMPONENTS& channels = Components::getSingleton().getComponents(serverComponentType_);
    Components::COMPONENTS::iterator iter1 = channels.begin();
    uint8 dataType = dataType_;
    ArraySize slen = 0;

    for(; iter1 != channels.end(); iter1++)
    {
        Mercury::Channel* lpChannel = iter1->pChannel;
        KBE_ASSERT(lpChannel != NULL);

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

        (*pBundle).newMessage(DbmgrInterface::onBroadcastGlobalDataChange);

        (*pBundle) << dataType;
        (*pBundle) << isDelete;

        slen = key.size();
        (*pBundle) << slen;
        (*pBundle).assign(key.data(), slen);

        if(!isDelete)
        {
            slen = value.size();
            (*pBundle) << slen;
            (*pBundle).assign(value.data(), slen);
        }

        (*pBundle) << g_componentType;

        (*pBundle).send(*lpChannel->endpoint());
        Mercury::Bundle::ObjPool().reclaimObject(pBundle);
    }
}
开发者ID:sdsgwangpeng,项目名称:kbengine,代码行数:37,代码来源:globaldata_client.cpp

示例2: broadcastDataChange

//-------------------------------------------------------------------------------------
void GlobalDataServer::broadcastDataChange(Mercury::Channel* pChannel, COMPONENT_TYPE componentType, 
										const std::string& key, const std::string& value, bool isDelete)
{
	INFO_MSG(boost::format("GlobalDataServer::broadcastDataChange: writer(%1%), key_size=%2%, val_size=%3%, isdelete=%4%.\n") %
		COMPONENT_NAME_EX(componentType) % key.size() % value.size() % (int)isDelete);

	std::vector<COMPONENT_TYPE>::iterator iter = concernComponentTypes_.begin();
	for(; iter != concernComponentTypes_.end(); iter++)
	{
		COMPONENT_TYPE ct = (*iter);
		Components::COMPONENTS& channels = Components::getSingleton().getComponents(ct);
		Components::COMPONENTS::iterator iter1 = channels.begin();
		
		for(; iter1 != channels.end(); iter1++)
		{
			Mercury::Channel* lpChannel = iter1->pChannel;
			KBE_ASSERT(lpChannel != NULL);

			if(pChannel == lpChannel)
				continue;

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

			switch(dataType_)
			{
			case GLOBAL_DATA:
				if(componentType == CELLAPP_TYPE)
				{
					(*pBundle).newMessage(CellappInterface::onBroadcastGlobalDataChange);
				}
				else if(componentType == BASEAPP_TYPE)
				{
					(*pBundle).newMessage(BaseappInterface::onBroadcastGlobalDataChange);
				}
				else
				{
					KBE_ASSERT(false && "componentType is error!\n");
				}
				break;
			case GLOBAL_BASES:
				(*pBundle).newMessage(BaseappInterface::onBroadcastGlobalBasesChange);
				break;
			case CELLAPP_DATA:
				(*pBundle).newMessage(CellappInterface::onBroadcastCellAppDataChange);
				break;
			default:
				KBE_ASSERT(false && "dataType is error!\n");
				break;
			};

			
			(*pBundle) << isDelete;
			ArraySize slen = key.size();
			(*pBundle) << slen;
			(*pBundle).assign(key.data(), slen);

			if(!isDelete)
			{
				slen = value.size();
				(*pBundle) << slen;
				(*pBundle).assign(value.data(), slen);
			}

			(*pBundle).send(*lpChannel->endpoint());
			Mercury::Bundle::ObjPool().reclaimObject(pBundle);
		}
	}
}
开发者ID:fengqk,项目名称:kbengine,代码行数:69,代码来源:globaldata_server.cpp


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