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


C++ LPDESC::GetHostName方法代码示例

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


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

示例1: Handshake

void CInputUDP::Handshake(LPDESC pDesc, const char * c_pData)
{
	TPacketCGHandshake * pInfo = (TPacketCGHandshake *) c_pData;

	if (pDesc->GetHandshake() == pInfo->dwHandshake)
	{
		sys_log(0, "UDP: Grant %s:%d", inet_ntoa(m_SockAddr.sin_addr), m_SockAddr.sin_port);
		pDesc->UDPGrant(m_SockAddr);
		return;
	}
	else
		sys_log(0, "UDP: Handshake differs %s", pDesc->GetHostName());
}
开发者ID:Rarder44,项目名称:Server,代码行数:13,代码来源:input_udp.cpp

示例2: Analyze

int CInputHandshake::Analyze(LPDESC d, BYTE bHeader, const char * c_pData)
{
	if (bHeader == 10) // 엔터는 무시
		return 0;

	if (bHeader == HEADER_CG_TEXT)
	{
		++c_pData;
		const char * c_pSep;

		if (!(c_pSep = strchr(c_pData, '\n')))	// \n을 찾는다.
			return -1;

		if (*(c_pSep - 1) == '\r')
			--c_pSep;

		std::string stResult;
		std::string stBuf;
		stBuf.assign(c_pData, 0, c_pSep - c_pData);

		sys_log(0, "SOCKET_CMD: FROM(%s) CMD(%s)", d->GetHostName(), stBuf.c_str());

		if (!stBuf.compare("IS_SERVER_UP"))
		{
			if (g_bNoMoreClient)
				stResult = "NO";
			else
				stResult = "YES";
		}
		else if (!stBuf.compare("IS_PASSPOD_UP"))
		{
			if (g_bNoPasspod)
				stResult = "NO";
			else
				stResult = "YES";
		}
		//else if (!stBuf.compare("SHOWMETHEMONEY"))
		else if (stBuf == g_stAdminPagePassword)
		{
			if (!IsEmptyAdminPage())
			{
				if (!IsAdminPage(inet_ntoa(d->GetAddr().sin_addr)))
				{
					char szTmp[64];
					snprintf(szTmp, sizeof(szTmp), "WEBADMIN : Wrong Connector : %s", inet_ntoa(d->GetAddr().sin_addr));
					stResult += szTmp;
				}
				else
				{
					d->SetAdminMode();
					stResult = "UNKNOWN";
				}
			}
			else
			{
				d->SetAdminMode();
				stResult = "UNKNOWN";
			}
		}
		else if (!stBuf.compare("USER_COUNT"))
		{
			char szTmp[64];

			if (!IsEmptyAdminPage())
			{
				if (!IsAdminPage(inet_ntoa(d->GetAddr().sin_addr)))
				{
					snprintf(szTmp, sizeof(szTmp), "WEBADMIN : Wrong Connector : %s", inet_ntoa(d->GetAddr().sin_addr));
				}
				else
				{
					int iTotal;
					int * paiEmpireUserCount;
					int iLocal;
					DESC_MANAGER::instance().GetUserCount(iTotal, &paiEmpireUserCount, iLocal);
					snprintf(szTmp, sizeof(szTmp), "%d %d %d %d %d", iTotal, paiEmpireUserCount[1], paiEmpireUserCount[2], paiEmpireUserCount[3], iLocal);
				}
			}
			else
			{
				int iTotal;
				int * paiEmpireUserCount;
				int iLocal;
				DESC_MANAGER::instance().GetUserCount(iTotal, &paiEmpireUserCount, iLocal);
				snprintf(szTmp, sizeof(szTmp), "%d %d %d %d %d", iTotal, paiEmpireUserCount[1], paiEmpireUserCount[2], paiEmpireUserCount[3], iLocal);
			}
			stResult += szTmp;
		}
		else if (!stBuf.compare("CHECK_P2P_CONNECTIONS"))
		{
			std::ostringstream oss(std::ostringstream::out);
			
			oss << "P2P CONNECTION NUMBER : " << P2P_MANAGER::instance().GetDescCount() << "\n";
			std::string hostNames;
			P2P_MANAGER::Instance().GetP2PHostNames(hostNames);
			oss << hostNames;
			stResult = oss.str();
			TPacketGGCheckAwakeness packet;
			packet.bHeader = HEADER_GG_CHECK_AWAKENESS;

//.........这里部分代码省略.........
开发者ID:jgebbiken,项目名称:shizuka3,代码行数:101,代码来源:input.cpp

示例3: SetPhase

void CLIENT_DESC::SetPhase(int iPhase)
{
    switch (iPhase)
    {
    case PHASE_CLIENT_CONNECTING:
        sys_log(1, "PHASE_CLIENT_DESC::CONNECTING");
        m_pInputProcessor = NULL;
        break;

    case PHASE_DBCLIENT:
    {
        sys_log(1, "PHASE_DBCLIENT");

        if (!g_bAuthServer)
        {
            static bool bSentBoot = false;

            if (!bSentBoot)
            {
                bSentBoot = true;
                TPacketGDBoot p;
                p.dwItemIDRange[0] = 0;
                p.dwItemIDRange[1] = 0;
                memcpy(p.szIP, g_szPublicIP, 16);
                DBPacket(HEADER_GD_BOOT, 0, &p, sizeof(p));
            }
        }

        TEMP_BUFFER buf;

        TPacketGDSetup p;

        memset(&p, 0, sizeof(p));
        strlcpy(p.szPublicIP, g_szPublicIP, sizeof(p.szPublicIP));

        if (!g_bAuthServer)
        {
            p.bChannel	= g_bChannel;
            p.wListenPort = mother_port;
            p.wP2PPort	= p2p_port;
            p.bAuthServer = false;
            map_allow_copy(p.alMaps, 32);

            const DESC_MANAGER::DESC_SET & c_set = DESC_MANAGER::instance().GetClientSet();
            DESC_MANAGER::DESC_SET::const_iterator it;

            for (it = c_set.begin(); it != c_set.end(); ++it)
            {
                LPDESC d = *it;

                if (d->GetAccountTable().id != 0)
                    ++p.dwLoginCount;
            }

            buf.write(&p, sizeof(p));

            if (p.dwLoginCount)
            {
                TPacketLoginOnSetup pck;

                for (it = c_set.begin(); it != c_set.end(); ++it)
                {
                    LPDESC d = *it;

                    TAccountTable & r = d->GetAccountTable();

                    if (r.id != 0)
                    {
                        pck.dwID = r.id;
                        strlcpy(pck.szLogin, r.login, sizeof(pck.szLogin));
                        strlcpy(pck.szSocialID, r.social_id, sizeof(pck.szSocialID));
                        strlcpy(pck.szHost, d->GetHostName(), sizeof(pck.szHost));
                        pck.dwLoginKey = d->GetLoginKey();
#ifndef _IMPROVED_PACKET_ENCRYPTION_
                        thecore_memcpy(pck.adwClientKey, d->GetDecryptionKey(), 16);
#endif

                        buf.write(&pck, sizeof(TPacketLoginOnSetup));
                    }
                }
            }

            sys_log(0, "DB_SETUP current user %d size %d", p.dwLoginCount, buf.size());

            // 파티를 처리할 수 있게 됨.
            CPartyManager::instance().EnablePCParty();
            //CPartyManager::instance().SendPartyToDB();
        }
        else
        {
            p.bAuthServer = true;
            buf.write(&p, sizeof(p));
        }

        DBPacket(HEADER_GD_SETUP, 0, buf.read_peek(), buf.size());
        m_pInputProcessor = &m_inputDB;
    }
    break;

    case PHASE_P2P:
//.........这里部分代码省略.........
开发者ID:cCorax2,项目名称:Source_code,代码行数:101,代码来源:desc_client.cpp


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