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


C++ SystemAddress类代码示例

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


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

示例1: OnAck

void PacketLogger::OnAck(unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNetTime time)
{
	char str[256];
	char str1[64], str2[62];
	SystemAddress localSystemAddress = rakPeerInterface->GetExternalID(remoteSystemAddress);
	localSystemAddress.ToString(true, str1);
	remoteSystemAddress.ToString(true, str2);
	char localtime[128];
	GetLocalTime(localtime);

	sprintf(str, "%s,Rcv,Ack,%i,,,,%"PRINTF_64_BIT_MODIFIER"u,%s,%s,,,,,,"
					, localtime
					, messageNumber
					, (unsigned long long) time
					, str1
					, str2
					);
	AddToLog(str);
}
开发者ID:DaanRuiter,项目名称:Networking,代码行数:19,代码来源:PacketLogger.cpp

示例2: FormatLine

void PacketLogger::FormatLine(
char* into, const char* dir, const char* type, unsigned int reliableMessageNumber, unsigned int frame, const char* idToPrint
, const BitSize_t bitLen, unsigned long long time, const SystemAddress& local, const SystemAddress& remote,
unsigned int splitPacketId, unsigned int splitPacketIndex, unsigned int splitPacketCount, unsigned int orderingIndex)
{
	char str1[64], str2[62];
	local.ToString(true, str1);
	remote.ToString(true, str2);
	char localtime[128];
	GetLocalTime(localtime);
	char str3[64];
	if (reliableMessageNumber==(unsigned int)-1)
	{
		str3[0]='N';
		str3[1]='/';
		str3[2]='A';
		str3[3]=0;
	}
	else
	{
		sprintf(str3,"%5u",reliableMessageNumber);
	}

	sprintf(into, "%s,%s%s,%s,%s,%5u,%s,%u,%" PRINTF_64_BIT_MODIFIER "u,%s,%s,%i,%i,%i,%i,%s,"
					, localtime
					, prefix
					, dir
					, type
					, str3
					, frame
					, idToPrint
					, bitLen
					, time
					, str1
					, str2
					, splitPacketId
					, splitPacketIndex
					, splitPacketCount
					, orderingIndex
					, suffix
					);
}
开发者ID:MarekBillington,项目名称:Batteries_Not_Included,代码行数:42,代码来源:PacketLogger.cpp

示例3: printf

void FullyConnectedMesh2::SendFCMGuidRequest(SystemAddress addr)
{
#ifdef DEBUG_FCM2
	printf("SendFCMGuidRequest to %s. guid=%s.\n", addr.ToString(), rakPeerInterface->GetGuidFromSystemAddress(addr).ToString());
#endif

	RakNet::BitStream bsOut;
	bsOut.Write((MessageID)ID_FCM2_REQUEST_FCMGUID);
	bsOut.Write(GetElapsedRuntime());
	rakPeerInterface->Send(&bsOut,HIGH_PRIORITY,RELIABLE_ORDERED,0,addr,false);
}
开发者ID:DreamNex,项目名称:MultiplayerA2,代码行数:11,代码来源:FullyConnectedMesh2.cpp

示例4: SendTTL

void NatPunchthroughClient::SendTTL(SystemAddress sa)
{
	if (sa==UNASSIGNED_SYSTEM_ADDRESS)
		return;
	if (sa.port==0)
		return;

	char ipAddressString[32];
	sa.ToString(false, ipAddressString);
	rakPeerInterface->SendTTL(ipAddressString,sa.port, 3);
}
开发者ID:FearlessSon,项目名称:Colin-AIE-Term-Project,代码行数:11,代码来源:NatPunchthroughClient.cpp

示例5: WriteMiscellaneous

void PacketLogger::WriteMiscellaneous(const char *type, const char *msg)
{
	char str[1024];
	char str1[64];
	SystemAddress localSystemAddress = rakPeerInterface->GetInternalID();
	localSystemAddress.ToString(true, str1);
	RakNetTime time = RakNet::GetTime();
	char localtime[128];
	GetLocalTime(localtime);

	sprintf(str, "%s,Lcl,%s,,,,,%"PRINTF_TIME_MODIFIER"u,%s,,,,,,,%s"
					, localtime
					, type
					, (unsigned long long) time
					, str1
					, msg
					);

	AddToLog(msg);
}
开发者ID:ThePirateOld,项目名称:four-mp,代码行数:20,代码来源:PacketLogger.cpp

示例6: OnPushBackPacket

void PacketLogger::OnPushBackPacket(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
{
	char str[256];
	char str1[64], str2[62];
	SystemAddress localSystemAddress = rakPeerInterface->GetExternalID(remoteSystemAddress);
	localSystemAddress.ToString(true, str1);
	remoteSystemAddress.ToString(true, str2);
	RakNetTime time = RakNet::GetTime();
	char localtime[128];
	GetLocalTime(localtime);

	sprintf(str, "%s,Lcl,PBP,,,%s,%i,%"PRINTF_TIME_MODIFIER"u,%s,%s,,,,,,"
					, localtime
					, BaseIDTOString(data[0])
					, bitsUsed
					, (unsigned long long) time
					, str1
					, str2
					);
	AddToLog(str);
}
开发者ID:ThePirateOld,项目名称:four-mp,代码行数:21,代码来源:PacketLogger.cpp

示例7: OnInvalidMessage

void MessageFilter::OnInvalidMessage(FilterSet *filterSet, SystemAddress systemAddress, unsigned char messageID)
{
	if (filterSet->invalidMessageCallback)
		filterSet->invalidMessageCallback(rakPeerInterface, systemAddress, filterSet->filterSetID, filterSet->disallowedCallbackUserData, messageID);
	if (filterSet->banOnDisallowedMessage) {
		char str1[64];
		systemAddress.ToString(false, str1);
		rakPeerInterface->AddToBanList(str1, filterSet->disallowedMessageBanTimeMS);
	}
	if (filterSet->kickOnDisallowedMessage)
		rakPeerInterface->CloseConnection(systemAddress, true, 0);
}
开发者ID:Codyle,项目名称:facilitator,代码行数:12,代码来源:MessageFilter.cpp

示例8: FixForIPVersion

void SystemAddress::FixForIPVersion(const SystemAddress &boundAddressToSocket)
{
    char str[128];
    ToString(false,str);
    if (strcmp(str, IPV6_LOOPBACK)==0)
    {
        if (boundAddressToSocket.GetIPVersion()==4)
        {
            FromString(IPV4_LOOPBACK,0,4);
        }
    }
    else if (strcmp(str, IPV4_LOOPBACK)==0)
    {
#if VENET_SUPPORT_IPV6==1
        if (boundAddressToSocket.GetIPVersion()==6)
        {
            FromString(IPV6_LOOPBACK,0,6);
        }
#endif

    }
}
开发者ID:snailwork,项目名称:Texas-cs,代码行数:22,代码来源:VENetTypes.cpp

示例9: while

void Server::Loop(){
	while(1){
		SystemAddress addresClient = peer->HasNewIncomingConnection();
		if(addresClient!=UNASSIGNED_SYSTEM_ADDRESS){
			std::cout << "[Client Connected]: "<<addresClient.ToString() <<std::endl;
			std::cout << "[Client Connected]: client count: " << peer->GetConnectionCount() <<std::endl;
			//std::cout << "[Client Connected]: client count: " <<  <<std::endl;
			SystemAddress  iplist[Settings::maxPlayers];
			unsigned short numberofSystems;
			peer->GetConnectionList(iplist,&numberofSystems);
			for(unsigned short i = 0;i<numberofSystems;i++){
				std::cout << "[Client Connected]: client " << i << ":" << iplist[i].ToString() <<std::endl;
			}
			playersManager.AddPlayer(addresClient);
			SendPlayerList();
			printf("\n");
		}else{
			break;
		}
	}
	while(1){
		SystemAddress addresClient = peer->HasLostConnection();
		if(addresClient!=UNASSIGNED_SYSTEM_ADDRESS){
			peer->CloseConnection(addresClient);
			std::cout << "[Client DisConnected]: "<<addresClient.ToString() <<std::endl;
			playersManager.RemovePlayer(addresClient);
			SendPlayerList();
			SendPlayerIsAdmin();
			printf("\n");
		}else{
			break;
		}
	}
	if(game != NULL){
		game->Loop();
	}
	Connector::Loop();
}
开发者ID:KitVanDeBunt,项目名称:snake-multiplayer,代码行数:38,代码来源:Server.cpp

示例10: switch

PluginReceiveResult FullyConnectedMesh2::OnReceive(Packet *packet)
{
	switch (packet->data[0])
	{
	case ID_REMOTE_NEW_INCOMING_CONNECTION:
		{
			if (connectOnNewRemoteConnections)
			{
				unsigned int count;
				RakNet::BitStream bsIn(packet->data, packet->length, false);
				bsIn.IgnoreBytes(sizeof(MessageID));
				bsIn.Read(count);
				SystemAddress remoteAddress;
				RakNetGUID remoteGuid;
				char str[64];
				for (unsigned int i=0; i < count; i++)
				{
					bsIn.Read(remoteAddress);
					bsIn.Read(remoteGuid);
					remoteAddress.ToString(false,str);
					rakPeerInterface->Connect(str,remoteAddress.port,connectionPassword.C_String(),(int) connectionPassword.GetLength());
				}
			}
		}
		break;
	case ID_FCM2_REQUEST_FCMGUID:
		OnRequestFCMGuid(packet);
		return RR_STOP_PROCESSING_AND_DEALLOCATE;
	case ID_FCM2_RESPOND_CONNECTION_COUNT:
		OnRespondConnectionCount(packet);
		return RR_STOP_PROCESSING_AND_DEALLOCATE;
	case ID_FCM2_INFORM_FCMGUID:
		OnInformFCMGuid(packet);
		return RR_STOP_PROCESSING_AND_DEALLOCATE;
	}
	return RR_CONTINUE_PROCESSING;
}
开发者ID:pulkomandy,项目名称:.theRush-,代码行数:37,代码来源:FullyConnectedMesh2.cpp

示例11: DoHandshake

void DoHandshake(RakPeerInterface *rakServer, const SystemAddress& systemAddress, RakNet::BitStream * data, std::string SERVER){
	unsigned long s_remoteConnectionType = 4;
	if (SERVER == "AUTH") s_remoteConnectionType = 1;
	unsigned long version;
	data->Read(version);
	unsigned long unknown;
	data->Read(unknown);
	unsigned long remoteConnectionType;
	data->Read(remoteConnectionType);
	unsigned long processid;
	data->Read(processid);
	unsigned short port;
	data->Read(port);
	std::vector<unsigned char> addv;
	addv.reserve(33);
	bool flag = true;
	std::string address = PacketTools::ReadStrFromPacket(data, 33); //Unused, no data
	Logger::log(SERVER, "", "Client: " + std::string(systemAddress.ToString()), LOG_ALL);
	Logger::log(SERVER, "", "Client Handshake Request", LOG_DEBUG);
	Logger::log(SERVER, "", "Version:        " + std::to_string(version), LOG_ALL);
	Logger::log(SERVER, "", "ProcessID:      " + std::to_string(processid), LOG_ALL);
	Logger::log(SERVER, "", "ConnectionType: " + std::to_string(remoteConnectionType), LOG_ALL);
	Logger::log(SERVER, "", "Port:           " + std::to_string(port), LOG_ALL);

	//Preparing answer:
	RakNet::BitStream *aw = new RakNet::BitStream(59);
	CreatePacketHeader(ID_USER_PACKET_ENUM, 0, 0, aw);
	unsigned long s_version = 171022UL;
	unsigned long s_unknown = 0x93;
	unsigned long s_processid = GetCurrentProcessId();
	short s_unknown2 = -1; //port = 0xFFFF = -1 -> no port?
	std::string s_ip = rakServer->GetLocalIP(0);
	Logger::log(SERVER, "", "Server Handshake Response", LOG_DEBUG);
	Logger::log(SERVER, "", "Version:        " + std::to_string(s_version), LOG_ALL);
	Logger::log(SERVER, "", "ProcessID:      " + std::to_string(s_processid), LOG_ALL);
	Logger::log(SERVER, "", "ConnectionType: " + std::to_string(s_remoteConnectionType), LOG_ALL);
	Logger::log(SERVER, "", "Address:        " + s_ip, LOG_ALL);
	aw->Write(s_version);
	aw->Write(s_unknown);
	aw->Write(s_remoteConnectionType);
	aw->Write(s_processid);
	aw->Write(s_unknown2);

	for (unsigned char k = 0; k < 33; k++){
		if (k < s_ip.size()) aw->Write((unsigned char)s_ip.at(k));
		else aw->Write((unsigned char)0);
	}
	rakServer->Send(aw, SYSTEM_PRIORITY, RELIABLE_ORDERED, 0, systemAddress, false);
}
开发者ID:CodeAequitas,项目名称:UniverseServer,代码行数:49,代码来源:Packet.cpp

示例12: OnNewConnection

void NatPunchthroughClient::OnNewConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
{
	(void) rakNetGUID;
	(void) isIncoming;

	// Try to track new port mappings on the router. Not reliable, but better than nothing.
	SystemAddress ourExternalId = rakPeerInterface->GetExternalID(systemAddress);
	if (ourExternalId!=UNASSIGNED_SYSTEM_ADDRESS)
		mostRecentNewExternalPort=ourExternalId.GetPort();

	unsigned int i;
	i=0;
	while (i < groupRequestsInProgress.Size())
	{
		if (groupRequestsInProgress[i].guid==rakNetGUID)
		{
			groupRequestsInProgress.RemoveAtIndexFast(i);
		}
		else
		{
			i++;
		}
	}
}
开发者ID:SuperMagicBadger,项目名称:Zombiess,代码行数:24,代码来源:NatPunchthroughClient.cpp

示例13: WaitForConnectionRequestsToComplete

void ManyClientsOneServerBlockingTest::WaitForConnectionRequestsToComplete(RakPeerInterface **clientList, int clientNum, bool isVerbose)
{
	SystemAddress currentSystem;
	bool msgWasPrinted=false;

	for (int i=0;i<clientNum;i++)
	{

		currentSystem.SetBinaryAddress("127.0.0.1");
		currentSystem.port=60000;

		while (CommonFunctions::ConnectionStateMatchesOptions (clientList[i],currentSystem,false,true,true) )
		{
			if (msgWasPrinted==false)
			{
				printf("Waiting for connection requests to complete.\n");
				msgWasPrinted=true;
			}

			RakSleep(30);
		}

	}
}
开发者ID:CaiZhongda,项目名称:ClashOfClans,代码行数:24,代码来源:ManyClientsOneServerBlockingTest.cpp

示例14: WaitForConnectionRequestsToComplete

void ManyClientsOneServerDeallocateBlockingTest::WaitForConnectionRequestsToComplete(RakPeerInterface **clientList, int clientNum, bool isVerbose)
{
	SystemAddress currentSystem;
	bool msgWasPrinted=false;

	for (int i=0;i<clientNum;i++)
	{

		currentSystem.SetBinaryAddress("127.0.0.1");
		currentSystem.port=60000;

		while (clientList[i]->IsConnectionAttemptPending (currentSystem) )
		{
			if (msgWasPrinted==false)
			{
				printf("Waiting for connection requests to complete.\n");
				msgWasPrinted=true;
			}

			RakSleep(30);
		}

	}
}
开发者ID:pulkomandy,项目名称:.theRush-,代码行数:24,代码来源:ManyClientsOneServerDeallocateBlockingTest.cpp

示例15: OnClosedConnection

	// Implemented event callback from base class PluginInterface2
	virtual void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason )
	{
		// Call down to the base class in case it does anything in the future (right now it does nothing)
		SQLite3ServerPlugin::OnClosedConnection(systemAddress, rakNetGUID, lostConnectionReason);

		// Get the database index associated with the table used for this class
		unsigned int idx = dbHandles.GetIndexOf(connectionStateIdentifier);
		if (idx==(unsigned int)-1)
			return;

		// Remove dropped system by primary key system address
		char systemAddressString[64];
		systemAddress.ToString(true,systemAddressString);
		RakNet::RakString query("DELETE FROM connectionState WHERE systemAddress='%s';",
			RakNet::RakString(systemAddressString).SQLEscape().C_String());
		sqlite3_exec(dbHandles[idx].dbHandle,query.C_String(),0,0,0);
	}
开发者ID:Darrenbydesign,项目名称:HoloToolkit,代码行数:18,代码来源:SQLite3Sample.cpp


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