• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ raknet::SystemAddress类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中raknet::SystemAddress的典型用法代码示例。如果您正苦于以下问题:C++ SystemAddress类的具体用法?C++ SystemAddress怎么用?C++ SystemAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: TServerDetails

void
CRakMasterServer::RegisterServer(RakNet::SystemAddress& _rServerAddress, RakNet::RakNetGUID& _rServerGuid, uchar* _ucpData, uint _uiLength)
{
	std::map<uint64, TServerDetails*>::iterator Entry = m_mRegisteredServers.find(_rServerGuid.g);


	if (Entry == m_mRegisteredServers.end())
	{
		TServerDetails* tpServerDetails = new TServerDetails();


		char sServerIp[256];
		_rServerAddress.ToString_Old(false, sServerIp);


		tpServerDetails->tAddress = _rServerAddress;
		tpServerDetails->tGuid = _rServerGuid;
		tpServerDetails->fUnregisterTimer = s_kfRegistrationTimeout;


		m_mRegisteredServers.insert( std::pair<uint64, TServerDetails*>(_rServerGuid.g, tpServerDetails) );


		LOG_MESSAGE("Registered Server. IP(%s) GUID(%llu)", _rServerAddress.ToString(), _rServerGuid.g);
	}
	else
	{
		Entry->second->fUnregisterTimer = s_kfRegistrationTimeout;


		LOG_MESSAGE("Re-registered Server. IP(%s) GUID(%llu)", _rServerAddress.ToString(), _rServerGuid.g);
	}
}
开发者ID:nulhax,项目名称:VOID,代码行数:33,代码来源:RakMasterServer.cpp


示例2: PrintStatus

	void PrintStatus( void ) {
		// enumerate local addresses
		size_t numAddresses = peer->GetNumberOfAddresses();
		if ( numAddresses ) {
			console.Print( PrintLevel::Normal, "Network primed on:\n" );
			for ( size_t i = 0u; i < numAddresses; i++ ) {
				Indent indent( 1u );
				console.Print( PrintLevel::Normal, "%i. %s\n",
					i + 1,
					peer->GetLocalIP( i )
				);
			}
		}
		else {
			console.Print( PrintLevel::Normal, "Network primed on %s\n",
				peer->GetMyBoundAddress().ToString()
			);
		}
		console.Print( PrintLevel::Normal, "GUID: %" PRIX64 "\n",
			myGUID
		);

		// get a list of remote connections
		uint16_t numRemoteSystems;
		peer->GetConnectionList( nullptr, &numRemoteSystems );
		RakNet::SystemAddress *remoteSystems = new RakNet::SystemAddress[numRemoteSystems];
		peer->GetConnectionList( remoteSystems, &numRemoteSystems );

		console.Print( PrintLevel::Normal, "%i connections (max: %i)\n",
			numRemoteSystems,
			peer->GetMaximumIncomingConnections()
		);
		if ( numRemoteSystems ) {
			console.Print( PrintLevel::Normal, "Listing active connections...\n" );
			for ( size_t i = 0u; i < numRemoteSystems; i++ ) {
				RakNet::SystemAddress *sa = &remoteSystems[i];
				Indent indent( 1u );

				std::string type;
				if ( sa->IsLANAddress() ) {
					type = " LAN";
				}
				else if ( sa->IsLoopback() ) {
					type = "LOOP";
				}
				else {
					type = "INET";
				}

				console.Print( PrintLevel::Normal, "%s: %s - %s\n",
					type.c_str(),
					sa->ToString(),
					connectionStateMessages[peer->GetConnectionState( *sa )]
				);
			}
		}
		delete[] remoteSystems;
	}
开发者ID:Razish,项目名称:xsngine,代码行数:58,代码来源:Network.cpp


示例3: is_in_same_network

bool Network::is_in_same_network(std::string const& other) const {
  RakNet::SystemAddress o;
  RakNet::SystemAddress self;
  if (o.FromString(other.c_str()) && self.FromString(external_id_.c_str())) {
    if (o.EqualsExcludingPort(self)) {
      return true;
    }
  }
  return false;
}
开发者ID:Simmesimme,项目名称:swift2d,代码行数:10,代码来源:Network.cpp


示例4: switch

// Returning false prevents the proxy from forwarding current packet to the client
bool
CProxy::HandleLoginSrvPacket(RakNet::Packet* pPacket, RakNet::SystemAddress& clientAddr, RakNet::BitStream& inStr, uchar opCode)
{
  uint off = inStr.GetReadOffset();

  switch (opCode)
  {
  case Opcodes::OP_LOGIN:
    bool bLoggedIn = false;

    inStr.Read(bLoggedIn);

    if (bLoggedIn)
    {
      ff::fmt(pan::debug, "({0}) Player successfully logged in.", clientAddr.ToString(false));

      // Do the switch to Area server here
    }

    break;
  }

  inStr.SetReadOffset(off);

  return true;
}
开发者ID:alexis-,项目名称:iwe,代码行数:27,代码来源:CProxy.cpp


示例5: canConnected

bool NetworkEngine::canConnected(RakNet::SystemAddress id)
{
	RakNet::SystemAddress connecteds[MAX_PLAYERS];
	unsigned short size = MAX_PLAYERS;
	//unsigned short pos = peer->NumberOfConnections();
	//peer->GetConnectionList(connecteds,&pos);
	peer->GetConnectionList((RakNet::SystemAddress*) &connecteds,&size);

	if(disconnecteds.size() > 0)
	{
		std::vector<RakNet::SystemAddress>::iterator it = disconnecteds.begin();
		do
		{
			if(id.EqualsExcludingPort(*it))
			{
				disconnecteds.erase(it);
				return true;
			}
			it++;
		}while(it != disconnecteds.end());
	}

	for(int i=0;i<MAX_PLAYERS;i++)
	{
		if(connecteds[i].EqualsExcludingPort(id))
		{
			return false;
		}
	}

	return false;
}
开发者ID:rubenmv,项目名称:SpaceDefenders,代码行数:32,代码来源:NetworkEngine.cpp


示例6: connect

void Connector::connect( RakNet::SystemAddress server ){
   
	if (raknetInterface == nullptr){
        LOG("Client is not started!");
        return;
    }

    char * ip = new char[64]; // must be new char[]! Not char ip[], BAD_ACCESS!!
    for(int i=0; i<64; i++){ ip[i] = 0; }
        
    server.ToString(false, ip);

	int result = raknetInterface->Connect(ip, server.GetPort(), RAKNET_PASSWORD, (int)strlen(RAKNET_PASSWORD));
    LOG("[Connector] Connecting to %s", ip);
    if(result == RakNet::CONNECTION_ATTEMPT_STARTED)
    {
        LOG("[Connector] Connecting to %s started.", ip);
    }
    else if (result == RakNet::INVALID_PARAMETER)
    {
        LOG("[Connector] INVALID_PARAMETER");
    }
    else if (result == RakNet::CANNOT_RESOLVE_DOMAIN_NAME)
    {
        LOG("[Connector] CANNOT_RESOLVE_DOMAIN_NAME");
    }

    else if (result == RakNet::ALREADY_CONNECTED_TO_ENDPOINT)
    {
        LOG("[Connector] ALREADY_CONNECTED_TO_ENDPOINT");
    }

    else if (result == RakNet::CONNECTION_ATTEMPT_ALREADY_IN_PROGRESS)
    {
        LOG("[Connector] CONNECTION_ATTEMPT_ALREADY_IN_PROGRESS");
    }

    else if (result == RakNet::SECURITY_INITIALIZATION_FAILED)
    {
        LOG("[Connector] SECURITY_INITIALIZATION_FAILED");
    }
    else{
        LOG("[Connector] connecting atempt failed for unknown reason!!!");
    }
    
    delete [] ip;
}
开发者ID:marekfoltyn,项目名称:InteractiveGame,代码行数:47,代码来源:Connector.cpp


示例7: sendMessagePlayerReconnected

void NetworkEngine::sendMessagePlayerReconnected(RakNet::SystemAddress systemAddress)
{
	//Envia un ID_SERVER_MESSAGE con un RakNet::String;
	RakNet::BitStream bitStream;
	RakNet::RakString string("Player %s has reconnected to the game\n", systemAddress.ToString());
	bitStream.Write((unsigned char)ID_SERVER_STRING_MESSAGE);
	bitStream.Write(string);
	peer->Send(&bitStream, HIGH_PRIORITY, RELIABLE, 0, RakNet::UNASSIGNED_SYSTEM_ADDRESS, true);
}
开发者ID:rubenmv,项目名称:SpaceDefenders,代码行数:9,代码来源:NetworkEngine.cpp


示例8: sendData

	void ClientChatNetPackageSender::sendData( const char* data, int lenght )
	{
		const NetworkAddress& networkAddress(getPeer()->getNetworkAddress());
		RakNet::SystemAddress target;
		target.FromStringExplicitPort(networkAddress.getServerIp(),networkAddress.getServerPort());

		// HIGH_PRIORITY doesn't actually matter here because we don't use any other priority
		// RELIABLE_ORDERED means make sure the message arrives in the right order
		// We arbitrarily pick 0 for the ordering stream
		// target.FromStringExplicitPort created the address to send the data to
		// false means send the message to the given target address

		RakNet::RakPeerInterface* rakNetPeer(getPeer()->accessRakNetPeer());
		// note: better check if the peer is connected in the first place
		if(rakNetPeer != nullptr)	{
			rakNetPeer->Send(data, lenght, 
				HIGH_PRIORITY, RELIABLE_ORDERED, 0, target, false);
		}
	}
开发者ID:Mobiletainment,项目名称:Multiplayer-Network-Conecpts,代码行数:19,代码来源:nlChatSample.cpp


示例9: addReceiveMessage

///加条发送的消息
void  SimulateClientMainFrame::addReceiveMessage(const std::string& message,const RakNet::SystemAddress& Address)
{
	wxString tem;
	tem+=Address.ToString();
	tem+=": ";
	tem+=message;
	tem+="\n";
	m_receiveText->AppendText(tem);

}
开发者ID:chenzhi,项目名称:yhzserver,代码行数:11,代码来源:SimulateClientMainFrame.cpp


示例10: processDatabasePlayer

//------------------------------------------------------------------------------------
void PlayerManager::processDatabasePlayer(NetPack* pPack)
{
	///把数据转发给客户端

	Tag_PlayerCollect* players=static_cast<Tag_PlayerCollect*>(pPack->getData());

	
	if(players->m_Count==0)///表示这个帐号还没有新建角色
	{


	}else                      ///把所有角色发给客户端
	{

	}

	RakNet::SystemAddress address;
	address.SetBinaryAddress(players->m_ip);
	NetWorkServer::getSingleton().send(GM_REQUEST_PLAYERS,(const char*)pPack->getData(),pPack->getDataLength(),address);


	return ;
}
开发者ID:chenzhi,项目名称:yhzserver,代码行数:24,代码来源:playermanager.cpp


示例11:

void
CProxy::OnClosedConnection(const RakNet::SystemAddress&       systemAddress,
                           RakNet::RakNetGUID                 rakNetGUID,
                           RakNet::PI2_LostConnectionReason   lostConnectionReason)
{
  ff::fmt(pan::notice, "({0}) Closed connection", systemAddress.ToString(false));

  s_clientInfos* pInfos = m_mapClientAddr[systemAddress];

  m_mapClientAddr.erase(systemAddress);

  std::map<uint, s_clientInfos*>::iterator it = m_mapClientId.find(pInfos->m_uID);
  if (it != m_mapClientId.end())
    m_mapClientId.erase(it);
}
开发者ID:alexis-,项目名称:iwe,代码行数:15,代码来源:CProxy.cpp


示例12: run

void Network_module::run()
{
    print_config();

    using namespace RakNet;
    RakNet::RakPeerInterface* l_rakpeer = RakNet::RakPeerInterface::GetInstance();

    int l_addr_count = l_rakpeer->GetNumberOfAddresses();
    NET_MOD_INFO("获取到本机IP数量%d个", l_addr_count);

    for (int i = 0; i < l_addr_count; i++)
    {
        RakNet::SystemAddress addr = l_rakpeer->GetLocalIP(i);
        NET_MOD_INFO("第%d个IP地址为:%s", i + 1, addr.ToString(false));
    }

    RakNet::SocketDescriptor l_socket_descriptor;
    l_socket_descriptor.port = m_local_port;

    if (l_rakpeer->Startup(m_max_connection, &l_socket_descriptor, 1) != RakNet::RAKNET_STARTED)
    {
        NET_MOD_ERROR("启动网络引擎失败");
        RakNet::RakPeerInterface::DestroyInstance(l_rakpeer);
        return;
    }

    l_rakpeer->SetMaximumIncomingConnections(m_max_income_connection);

    NET_MOD_INFO("启动网络引擎成功,监控地址为%s", l_rakpeer->GetMyBoundAddress().ToString(false));

    NET_MOD_INFO("开始载入打孔插件");
    m_punch_proxy = new NatPunchProxy;
    m_punch_proxy->init_proxy(l_rakpeer);

    start_network_loop(l_rakpeer);
}
开发者ID:watchmon,项目名称:BSdk,代码行数:36,代码来源:network_module.cpp


示例13: main


//.........这里部分代码省略.........
                // You won't see these unless you modified CloudServer
                printf("Server rejected the connection.\n");
                return 1;
            case ID_INCOMPATIBLE_PROTOCOL_VERSION:
                printf("Server is running an incompatible RakNet version.\n");
                return 1;
            case ID_NO_FREE_INCOMING_CONNECTIONS:
                printf("Server has no free connections\n");
                return 1;
            case ID_IP_RECENTLY_CONNECTED:
                printf("Recently connected. Retrying.");
                rakPeer->Connect(serverAddress, serverPort, 0, 0);
                break;
            case ID_CONNECTION_REQUEST_ACCEPTED:
                printf("Connected to server.\n");
                UploadInstanceToCloud(&cloudClient, packet->guid);
                GetClientSubscription(&cloudClient, packet->guid);
                GetServers(&cloudClient, packet->guid);
                break;
            case ID_CLOUD_GET_RESPONSE:
            {
                RakNet::CloudQueryResult cloudQueryResult;
                cloudClient.OnGetReponse(&cloudQueryResult, packet);
                unsigned int rowIndex;
                const bool wasCallToGetServers=cloudQueryResult.cloudQuery.keys[0].primaryKey=="CloudConnCount";
                printf("\n");
                if (wasCallToGetServers)
                    printf("Downloaded server list. %i servers.\n", cloudQueryResult.rowsReturned.Size());
                else
                    printf("Downloaded client list. %i clients.\n", cloudQueryResult.rowsReturned.Size());

                unsigned short connectionsOnOurServer=65535;
                unsigned short lowestConnectionsServer=65535;
                RakNet::SystemAddress lowestConnectionAddress;

                for (rowIndex=0; rowIndex < cloudQueryResult.rowsReturned.Size(); rowIndex++)
                {
                    RakNet::CloudQueryRow *row = cloudQueryResult.rowsReturned[rowIndex];
                    if (wasCallToGetServers)
                    {
                        unsigned short connCount;
                        RakNet::BitStream bsIn(row->data, row->length, false);
                        bsIn.Read(connCount);
                        printf("%i. Server found at %s with %i connections\n", rowIndex+1, row->serverSystemAddress.ToString(true), connCount);

                        unsigned short connectionsExcludingOurselves;
                        if (row->serverGUID==packet->guid)
                            connectionsExcludingOurselves=connCount-1;
                        else
                            connectionsExcludingOurselves=connCount;


                        // Find the lowest load server (optional)
                        if (packet->guid==row->serverGUID)
                        {
                            connectionsOnOurServer=connectionsExcludingOurselves;
                        }
                        else if (connectionsExcludingOurselves < lowestConnectionsServer)
                        {
                            lowestConnectionsServer=connectionsExcludingOurselves;
                            lowestConnectionAddress=row->serverSystemAddress;
                        }
                    }
                    else
                    {
                        printf("%i. Client found at %s", rowIndex+1, row->clientSystemAddress.ToString(true));
开发者ID:0521guo,项目名称:RakNet,代码行数:67,代码来源:CloudClientSample.cpp


示例14: ban

void Player::ban() const
{
    auto netCtrl = mwmp::Networking::getPtr();
    RakNet::SystemAddress addr = netCtrl->getSystemAddress(guid);
    netCtrl->banAddress(addr.ToString(false));
}
开发者ID:GrimKriegor,项目名称:openmw-tes3mp,代码行数:6,代码来源:Player.cpp


示例15: OnSendAborted

	virtual void OnSendAborted( RakNet::SystemAddress systemAddress )
	{
		char str[32];
		systemAddress.ToString(true, (char*) str);
		RAKNET_DEBUG_PRINTF("Send aborted to %s\n", str);	
	}
开发者ID:CaiZhongda,项目名称:ClashOfClans,代码行数:6,代码来源:main.cpp


示例16: OnFilePushesComplete

    virtual void OnFilePushesComplete( RakNet::SystemAddress systemAddress, unsigned short setID )
	{
		char str[32];
		systemAddress.ToString(true, (char*) str);
		RAKNET_DEBUG_PRINTF("File pushes complete to %s\n", str);	
	}
开发者ID:CaiZhongda,项目名称:ClashOfClans,代码行数:6,代码来源:main.cpp


示例17: Init

bool TetrisServer::Init()
{
	m_interface = RakNet::RakPeerInterface::GetInstance();
	RakNet::RakNetStatistics *rss;
	m_interface->SetIncomingPassword("Rumpelstiltskin", (int)strlen("Rumpelstiltskin"));
	m_interface->SetTimeoutTime(30000, RakNet::UNASSIGNED_SYSTEM_ADDRESS);

	// Record the first client that connects to us so we can pass it to the ping function
	m_clientID = RakNet::UNASSIGNED_SYSTEM_ADDRESS;
	// Holds user data
	char* portstring = "1234";

	printf("This is a sample implementation of a text based chat server.\n");
	printf("Connect to the project 'Chat Example Client'.\n");
	printf("Difficulty: Beginner\n\n");

	printf("Starting server.\n");
	// Starting the server is very simple.  2 players allowed.
	// 0 means we don't care about a connectionValidationInteger, and false
	// for low priority threads
	// I am creating two socketDesciptors, to create two sockets. One using IPV6 and the other IPV4
	RakNet::SocketDescriptor socketDescriptors[2];
	socketDescriptors[0].port = atoi(portstring);
	socketDescriptors[0].socketFamily = AF_INET; // Test out IPV4
	socketDescriptors[1].port = atoi(portstring);
	socketDescriptors[1].socketFamily = AF_INET6; // Test out IPV6
	bool b = m_interface->Startup(4, socketDescriptors, 2) == RakNet::RAKNET_STARTED;
	m_interface->SetMaximumIncomingConnections(4);
	if (!b)
	{
		printf("Failed to start dual IPV4 and IPV6 ports. Trying IPV4 only.\n");

		// Try again, but leave out IPV6
		b = m_interface->Startup(4, socketDescriptors, 1) == RakNet::RAKNET_STARTED;
		if (!b)
		{
			printf("Server failed to start.  Terminating.\n");
			return false;
		}
	}
	m_interface->SetOccasionalPing(true);
	m_interface->SetUnreliableTimeout(1000);

	DataStructures::List< RakNet::RakNetSocket2* > sockets;
	m_interface->GetSockets(sockets);
	printf("Socket addresses used by RakNet:\n");
	for (unsigned int i = 0; i < sockets.Size(); i++)
	{
		printf("%i. %s\n", i + 1, sockets[i]->GetBoundAddress().ToString(true));
	}

	printf("\nMy IP addresses:\n");
	for (unsigned int i = 0; i < m_interface->GetNumberOfAddresses(); i++)
	{
		RakNet::SystemAddress sa = m_interface->GetInternalID(RakNet::UNASSIGNED_SYSTEM_ADDRESS, i);
		printf("%i. %s (LAN=%i)\n", i + 1, sa.ToString(false), sa.IsLANAddress());
	}

	printf("\nMy GUID is %s\n", m_interface->GetGuidFromSystemAddress(RakNet::UNASSIGNED_SYSTEM_ADDRESS).ToString());

	return true;
}
开发者ID:kmiron,项目名称:SFMLTetris,代码行数:62,代码来源:Networking.cpp


示例18: Loop

void TetrisServer::Loop()
{
	// This sleep keeps RakNet responsive
	RakSleep(16);

	// GetPacketIdentifier returns this
	unsigned char packetIdentifier;

	for (p = m_interface->Receive(); p; m_interface->DeallocatePacket(p), p = m_interface->Receive())
	{
		// We got a packet, get the identifier with our handy function
		packetIdentifier = GetPacketIdentifier(p);

		// Check if this is a network message packet
		switch (packetIdentifier)
		{
		case ID_DISCONNECTION_NOTIFICATION:
			// Connection lost normally
			printf("ID_DISCONNECTION_NOTIFICATION from %s\n", p->systemAddress.ToString(true));;
			break;

		case ID_NEW_INCOMING_CONNECTION:
			// Somebody connected.  We have their IP now
			printf("ID_NEW_INCOMING_CONNECTION from %s with GUID %s\n", p->systemAddress.ToString(true), p->guid.ToString());
			m_clientID = p->systemAddress; // Record the player ID of the client

			printf("Remote internal IDs:\n");
			for (int index = 0; index < MAXIMUM_NUMBER_OF_INTERNAL_IDS; index++)
			{
				RakNet::SystemAddress internalId = m_interface->GetInternalID(p->systemAddress, index);
				if (internalId != RakNet::UNASSIGNED_SYSTEM_ADDRESS)
				{
					printf("%i. %s\n", index + 1, internalId.ToString(true));
				}
			}

			break;

		case ID_INCOMPATIBLE_PROTOCOL_VERSION:
			printf("ID_INCOMPATIBLE_PROTOCOL_VERSION\n");
			break;

		case ID_CONNECTED_PING:
		case ID_UNCONNECTED_PING:
			printf("Ping from %s\n", p->systemAddress.ToString(true));
			break;

		case ID_CONNECTION_LOST:
			// Couldn't deliver a reliable packet - i.e. the other system was abnormally
			// terminated
			printf("ID_CONNECTION_LOST from %s\n", p->systemAddress.ToString(true));;
			break;

		default:
			break;
		}
	}

	if (sf::Keyboard::isKeyPressed(sf::Keyboard::B))
	{

		// Message now holds what we want to broadcast
		char message[2048] = "Hello!";

		// message2 is the data to send
		// strlen(message2)+1 is to send the null terminator
		// HIGH_PRIORITY doesn't actually matter here because we don't use any other priority
		// RELIABLE_ORDERED means make sure the message arrives in the right order
		// We arbitrarily pick 0 for the ordering stream
		// RakNet::UNASSIGNED_SYSTEM_ADDRESS means don't exclude anyone from the broadcast
		// true means broadcast the message to everyone connected
		m_interface->Send(message, (const int)strlen(message) + 1, HIGH_PRIORITY, RELIABLE_ORDERED, 0, RakNet::UNASSIGNED_SYSTEM_ADDRESS, true);
	}
}
开发者ID:kmiron,项目名称:SFMLTetris,代码行数:74,代码来源:Networking.cpp


示例19: run

void Network_module::run()
{
    print_config();

    using namespace RakNet;

    int l_addr_count = m_rakpeer->GetNumberOfAddresses();
    NET_MOD_INFO("获取到本机IP数量%d个", l_addr_count);

    for (int i = 0; i < l_addr_count; i++)
    {
        RakNet::SystemAddress addr = m_rakpeer->GetLocalIP(i);
        NET_MOD_INFO("第%d个IP地址为:%s", i + 1, addr.ToString(false));
    }

    RakNet::SocketDescriptor l_socket_descriptor;
    l_socket_descriptor.port = m_local_port;

    if (m_rakpeer->Startup(m_max_connection, &l_socket_descriptor, 1) != RakNet::RAKNET_STARTED)
    {
        NET_MOD_ERROR("启动网络引擎失败");
        RakNet::RakPeerInterface::DestroyInstance(m_rakpeer);
        return;
    }

    m_rakpeer->SetMaximumIncomingConnections(m_max_income_connection);

    NET_MOD_INFO("启动网络引擎成功,监控地址为%s", m_rakpeer->GetMyBoundAddress().ToString(false));

    NET_MOD_INFO("开始载入打孔插件");
    m_punch_proxy->init_proxy(m_rakpeer);

    if (m_rakpeer->Connect(DEFAULT_SERVER_IP, DEFAULT_SERVER_PORT, 0, 0) != RakNet::CONNECTION_ATTEMPT_STARTED)
    {
        NET_MOD_ERROR("网络引擎,尝试连接失败");
        return;
    }

    NET_MOD_INFO("尝试连接服务器IP地址为%s,端口为%d", DEFAULT_SERVER_IP, DEFAULT_SERVER_PORT);
    RakNet::Packet* packet = NULL;

    int flag = true;

    while (flag)
    {
        for (packet=m_rakpeer->Receive(); packet; m_rakpeer->DeallocatePacket(packet), packet=m_rakpeer->Receive())
        {
            if (packet->data[0]==ID_CONNECTION_REQUEST_ACCEPTED)
            {
                NET_MOD_INFO("连接服务器%s:%d成功", DEFAULT_SERVER_IP, DEFAULT_SERVER_PORT);

                if (m_server_addr)
                {
                    delete m_server_addr;
                }

                m_server_addr = new RakNet::SystemAddress;
                *m_server_addr = packet->systemAddress;
                flag = false;
                break;
            }
            else
            {
                NET_MOD_ERROR("连接服务器失败");
                return;
            }
        }
    }

    start_network_loop();
}
开发者ID:watchmon,项目名称:BSdk,代码行数:71,代码来源:network_module.cpp


示例20: getIP

std::string Player::getIP() const
{
    RakNet::SystemAddress addr = mwmp::Networking::getPtr()->getSystemAddress(guid);
    return addr.ToString(false);
}
开发者ID:GrimKriegor,项目名称:openmw-tes3mp,代码行数:5,代码来源:Player.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ rangelikelihood::Ptr类代码示例发布时间:2022-05-31
下一篇:
C++ raknet::RakString类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap