Пример #1
0
BOOL P2PManager::RunP2P(char* szIP, unsigned short Port)
{
	GetPuCfgInstance().Init();
	GetPuLogInstance().Init();

	SetIdleTime(1000);
	SetSessionTimeout(8);//5

	GetPuCfgInstance().SetSerial( 0 );

	//
	if (THREADSTATUS_ZOMBIE == GetThreadStatus())
	{

		SetReceivePktQueue(FALSE);
		SetBindInfo("0.0.0.0", 0, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF);

		SetRelayInfo( szIP, Port );

		if (TRUE == CPuPeers::Start())
		{

			

			GetSelfLocalInfo(m_sinLocal);

			SendCheckExternalIp();
			SendCheckExternalIp();
		}
	}

	return TRUE;
}
Пример #2
0
	Bool CAppGateway::Init()
	{
		const CAppFrame::AppCfg& sCfg = *m_pApp->GetAppCfg();
		if (!BaseGateway::Init(sCfg.Gateway.Address,sCfg.Gateproxy.Address, sCfg.Gateway.Threads, sCfg.Gateway.Mode))
		{
			FmtPrint("AppGateway Init Error, Addr: %s, Threads: %d, Mode: %d", sCfg.Gateway.Address.c_str(), sCfg.Gateway.Threads, sCfg.Gateway.Mode);
			return false;
		}

		//加密模式
		if (sCfg.Gateway.Security)
			TurnGateSecurity();

		//性能监视
		if (sCfg.Gateway.Profiler.size())
			TurnOnProfiler(sCfg.Gateway.Profiler);

		//设置超时
		SetSessionTimeout(sCfg.Gateway.Timeout);

		//开启网关服务器线程
		if (!m_pThread)
		{
			m_pThread = new CThread(fun_AppFrameGatewayRoutine);
			m_pThread->Start(this);
		}

		return true;
	}
Пример #3
0
	Bool HsGateway::Init(const AString& sCfg)
	{
		if (!m_bRunning)
		{
			HawkXmlFile xmlCfg;
			HawkXmlDocument<AString> xmlDoc;
			if (!xmlCfg.Open(sCfg, xmlDoc))
			{
				HawkPrint("Gateway Open Config Error.");
				return false;
			}

			AXmlElement* pRoot  = xmlDoc.GetRoot();
			AXmlElement* pCfg   = pRoot->GetChildren("GwCfg");

			if(!pCfg || !pCfg->GetAttribute("Frontend") || !pCfg->GetAttribute("Backend"))
			{
				HawkPrint("Gateway Config Tag Error.");
				return false;
			}

			AString sFrontend = pCfg->GetAttribute("Frontend")->StringValue();
			AString sBackend  = pCfg->GetAttribute("Backend")->StringValue();
			HawkStringUtil::Replace<AString>(sBackend, "*", "127.0.0.1");

			Int32 iThread     = 4;
			if (pCfg->GetAttribute("Threads"))
				iThread = pCfg->GetAttribute("Threads")->IntValue();
			
			Bool bCrossDomain = false;
			if (pCfg->GetAttribute("CrossDomain"))
				bCrossDomain = pCfg->GetAttribute("CrossDomain")->BoolValue();

			if (pCfg->GetAttribute("Platform"))
				m_iPlatform = pCfg->GetAttribute("Platform")->IntValue();

			AString sProfiler = "";
			if (pCfg->GetAttribute("Profiler"))
				sProfiler = pCfg->GetAttribute("Profiler")->StringValue();

			Int32 iKeepAlive = 0;
			if (pCfg->GetAttribute("KeepAlive"))
				iKeepAlive = pCfg->GetAttribute("KeepAlive")->IntValue();

			if (HawkGateway::Init(sFrontend, sBackend, iThread))
			{
				P_ProtocolManager->SetSizeLimit(PAGE_SIZE);

				if (iKeepAlive > 0)
					SetSessionTimeout(iKeepAlive);

				if (bCrossDomain)
					TurnOnCrossDomain();

				if (sProfiler.size())
					TurnOnProfiler(sProfiler);

				return true;
			}
		}
		return false;
	}