本文整理汇总了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);
}
示例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
);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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
}
}
示例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();
}
示例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;
}
示例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);
}
示例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++;
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}