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


C++ ObjectPtr::GetRemoteInstance方法代码示例

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


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

示例1: timeout

void OOCore::UserSession::start()
{
#if defined(NDEBUG)
	OOBase::Timeout timeout(15,0);
#else
	OOBase::Timeout timeout;
#endif

	OOBase::StackAllocator<256> allocator;
	OOBase::LocalString strPipe(allocator);
	discover_server_port(strPipe,timeout);

	// Connect up to the user process...
	int err = 0;
	while (!timeout.has_expired())
	{
		m_stream = OOBase::Socket::connect_local(strPipe.c_str(),err,timeout);
		if (!err || (err != ENOENT && err != ECONNREFUSED))
			break;

		// We ignore the error, and try again until we timeout
	}
	if (err)
		OMEGA_THROW(err);

	// Send version information
	uint32_t version = (OOCORE_MAJOR_VERSION << 24) | (OOCORE_MINOR_VERSION << 16) | OOCORE_PATCH_VERSION;
	if ((err = m_stream->send(version)) != 0)
		OMEGA_THROW(err);

	// Read our channel id
	if ((err = m_stream->recv(m_channel_id)) != 0)
		OMEGA_THROW(err);

	// Create the zero compartment
	OOBase::SmartPtr<Compartment> ptrZeroCompt = new (OOCore::throwing) Compartment(this);
	ptrZeroCompt->set_id(0);

	// Register our local channel factory
	OOBase::Guard<OOBase::RWMutex> guard(m_lock);
	m_rot_cookies.push(OTL::GetModule()->RegisterAutoObjectFactory<OOCore::ChannelMarshalFactory>());

	// Create a new object manager for the user channel on the zero compartment
	if ((err = m_mapCompartments.force_insert(0,ptrZeroCompt)) != 0)
		OMEGA_THROW(err);

	guard.release();

	// Spawn off the io worker thread
	m_worker_thread.run(io_worker_fn,this);

	// Create a proxy to the server interface
	IObject* pIPS = NULL;
	ObjectPtr<Remoting::IObjectManager> ptrOM = ptrZeroCompt->get_channel_om(m_channel_id & 0xFF000000);
	ptrOM->GetRemoteInstance(OID_InterProcessService,Activation::Library | Activation::DontLaunch,OMEGA_GUIDOF(IInterProcessService),pIPS);
	ObjectPtr<IInterProcessService> ptrIPS = static_cast<IInterProcessService*>(pIPS);

	// Register the IPS...
	OTL::GetModule()->RegisterIPS(ptrIPS,false);

	// And register the Registry
	ObjectPtr<Registry::IKey> ptrReg;
	ptrReg.GetObject(Registry::OID_Registry_Instance);
	if (ptrReg)
	{
		// Re-register the proxy locally.. it saves a lot of time!
		ObjectPtr<Activation::IRunningObjectTable> ptrROT;
		ptrROT.GetObject(Activation::OID_RunningObjectTable_Instance);

		guard.acquire();

		m_rot_cookies.push(ptrROT->RegisterObject(Registry::OID_Registry_Instance,ptrReg,Activation::ProcessScope));
		m_rot_cookies.push(ptrROT->RegisterObject(string_t::constant("Omega.Registry"),ptrReg,Activation::ProcessScope));
	}
}
开发者ID:omegaonline,项目名称:oocore,代码行数:75,代码来源:Launch.cpp


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