本文整理汇总了C++中SystemAddress::ToString方法的典型用法代码示例。如果您正苦于以下问题:C++ SystemAddress::ToString方法的具体用法?C++ SystemAddress::ToString怎么用?C++ SystemAddress::ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SystemAddress
的用法示例。
在下文中一共展示了SystemAddress::ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Loop
void Server::Loop(){
while(1){
SystemAddress addresClient = peer->HasNewIncomingConnection();
if(addresClient!=UNASSIGNED_SYSTEM_ADDRESS){
std::cout << "[Client Connected]: "<<addresClient.ToString() <<std::endl;
playersManager.AddPlayer(addresClient);
SendPlayerList();
printf("\n");
}else{
break;
}
}
while(1){
SystemAddress addresClient = peer->HasLostConnection();
if(addresClient!=UNASSIGNED_SYSTEM_ADDRESS){
std::cout << "[Client DisConnected]: "<<addresClient.ToString() <<std::endl;
playersManager.RemovePlayer(addresClient);
SendPlayerList();
printf("\n");
}else{
break;
}
}
Connector::Loop();
}
示例2: SendOutOfBand
void NatPunchthroughClient::SendOutOfBand(SystemAddress sa, MessageID oobId)
{
if (sa==UNASSIGNED_SYSTEM_ADDRESS)
return;
if (sa.GetPort()==0)
return;
RakNet::BitStream oob;
oob.Write(oobId);
oob.Write(sp.sessionId);
// RakAssert(sp.sessionId<100);
if (oobId==ID_NAT_ESTABLISH_BIDIRECTIONAL)
oob.Write(sa.GetPort());
char ipAddressString[32];
sa.ToString(false, ipAddressString);
rakPeerInterface->SendOutOfBand((const char*) ipAddressString,sa.GetPort(),(const char*) oob.GetData(),oob.GetNumberOfBytesUsed());
if (natPunchthroughDebugInterface)
{
sa.ToString(true,ipAddressString);
char guidString[128];
sp.targetGuid.ToString(guidString);
if (oobId==ID_NAT_ESTABLISH_UNIDIRECTIONAL)
natPunchthroughDebugInterface->OnClientMessage(RakNet::RakString("Sent OOB ID_NAT_ESTABLISH_UNIDIRECTIONAL to guid %s, system address %s.", guidString, ipAddressString));
else
natPunchthroughDebugInterface->OnClientMessage(RakNet::RakString("Sent OOB ID_NAT_ESTABLISH_BIDIRECTIONAL to guid %s, system address %s.", guidString, ipAddressString));
}
}
示例3: FormatLine
void PacketLogger::FormatLine(
char* into, const char* dir, const char* type, unsigned int packet, 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);
sprintf(into, "%s,%s%s,%s,%5u,%5u,%s,%u,%"PRINTF_TIME_MODIFIER"u,%s,%s,%i,%i,%i,%i,%s,"
, localtime
, prefix
, dir
, type
, packet
, frame
, idToPrint
, bitLen
, time
, str1
, str2
, splitPacketId
, splitPacketIndex
, splitPacketCount
, orderingIndex
, suffix
);
}
示例4: SendOutOfBand
void NatPunchthroughClient::SendOutOfBand(SystemAddress sa, MessageID oobId)
{
if (sa==UNASSIGNED_SYSTEM_ADDRESS)
return;
if (sa.GetPort()==0)
return;
RakNet::BitStream oob;
oob.Write(oobId);
oob.Write(sp.sessionId);
// RakAssert(sp.sessionId<100);
if (oobId==ID_NAT_ESTABLISH_BIDIRECTIONAL)
oob.Write(sa.GetPort());
char ipAddressString[32];
sa.ToString(false, ipAddressString);
rakPeerInterface->SendOutOfBand((const char*) ipAddressString,sa.GetPort(),(const char*) oob.GetData(),oob.GetNumberOfBytesUsed());
if (natPunchthroughDebugInterface)
{
sa.ToString(true,ipAddressString);
char guidString[128];
sp.targetGuid.ToString(guidString);
// server - diff = my time
// server = myTime + diff
RakNet::Time clockDifferential = rakPeerInterface->GetClockDifferential(sp.facilitator);
RakNet::Time serverTime = RakNet::GetTime() + clockDifferential;
if (oobId==ID_NAT_ESTABLISH_UNIDIRECTIONAL)
natPunchthroughDebugInterface->OnClientMessage(RakNet::RakString("%I64d: %s: OOB ID_NAT_ESTABLISH_UNIDIRECTIONAL to guid %s, system address %s.\n", serverTime, TestModeToString(sp.testMode), guidString, ipAddressString));
else
natPunchthroughDebugInterface->OnClientMessage(RakNet::RakString("%I64d: %s: OOB ID_NAT_ESTABLISH_BIDIRECTIONAL to guid %s, system address %s.\n", serverTime, TestModeToString(sp.testMode), guidString, ipAddressString));
}
}
示例5: ReturnResult
void CommandParserInterface::ReturnResult(SystemAddress res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress)
{
char addr[128];
systemAddress.ToString(false,addr,static_cast<size_t>(128));
char addr2[128];
res.ToString(false,addr2,static_cast<size_t>(128));
transport->Send(systemAddress, "%s returned %s %s:%i\r\n", command,addr,addr2,res.GetPort());
}
示例6: failed
void FullyConnectedMesh2::AddParticipant(SystemAddress participant)
{
if (rakPeerInterface->IsConnected(participant,false,false)==false)
{
#ifdef DEBUG_FCM2
printf("AddParticipant to %s failed (not connected)\n", participant.ToString());
#endif
return;
}
// Account for different system addresses between different participants
RakNetGUID newParticipantGuid = rakPeerInterface->GetGuidFromSystemAddress(participant);
for (unsigned int i=0; i < participantList.Size(); i++)
{
if (participantList[i].rakNetGuid==newParticipantGuid)
{
if (participantList[i].systemAddress!=participant)
{
participantList[i].systemAddress=participant;
if (ourFCMGuid==0)
{
SendFCMGuidRequest(participant);
return;
}
else
{
SendOurFCMGuid(participant);
return;
}
}
#ifdef DEBUG_FCM2
printf("AddParticipant to %s failed (Same Guid and System address)\n", participant.ToString());
#endif
// else already added
return;
}
}
// Not in the list at all
if (ourFCMGuid==0)
{
SendFCMGuidRequest(participant);
guidRequestRetryList.Push(rakPeerInterface->GetGuidFromSystemAddress(participant),__FILE__,__LINE__);
}
else
{
SendOurFCMGuid(participant);
}
}
示例7: Start
bool Server::Start(void)
{
printf("Starting server!\n\n");
printf("Port: %i\n", m_port);
printf("Maximum clients: %i\n", m_noOfConnections);
m_server->SetIncomingPassword(m_password.c_str(), (int)strlen(m_password.c_str()));
m_server->SetTimeoutTime(30000, UNASSIGNED_SYSTEM_ADDRESS);
//m_server->AttachPlugin(&m_logger);
SocketDescriptor socketDesc[1];
socketDesc[0].port = m_port;
socketDesc[0].socketFamily = AF_INET;
bool started = m_server->Startup(m_noOfConnections, socketDesc, 1) == RAKNET_STARTED;
if (!started)
{
printf("Failed to start server!\n");
return false;
}
m_server->SetMaximumIncomingConnections(m_noOfConnections);
m_server->SetOccasionalPing(true);
m_server->SetUnreliableTimeout(true);
DataStructures::List<RakNetSocket2*> sockets;
m_server->GetSockets(sockets);
printf("\nSocket 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("\nIP Addresses:\n");
for (unsigned int i = 0; i < m_server->GetNumberOfAddresses(); ++i)
{
SystemAddress sa = m_server->GetInternalID(UNASSIGNED_SYSTEM_ADDRESS, i);
printf("%i. %s (LAN=%i)\n", i + 1, sa.ToString(true), sa.IsLANAddress());
SetConsoleTitle(sa.ToString(true));// (sa.ToString(true)));
}
printf("\nGUID: %s\n", m_server->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS).ToString());
printf("\nServer started!!\n\n\n");
return true;
}
示例8: bsIn
PluginReceiveResult FullyConnectedMesh2::OnReceive(Packet *packet)
{
switch (packet->data[0])
{
case ID_REMOTE_NEW_INCOMING_CONNECTION:
{
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,0,0);
}
}
break;
case ID_FCM2_REQUEST_FCMGUID:
OnRequestFCMGuid(packet);
break;
case ID_FCM2_RESPOND_FCMGUID:
OnRespondFCMGuid(packet);
break;
case ID_FCM2_INFORM_FCMGUID:
OnInformFCMGuid(packet);
break;
}
return RR_CONTINUE_PROCESSING;
}
示例9:
ACTIONSCRIPT_CALLABLE_FUNCTION(RoomsBrowserGFx3_RakNet, f2c_JoinByFilter)
{
if (pparams.GetArgCount()<1)
return;
RakNet::JoinByFilter_Func func;
func.userName=loginUsername;
func.gameIdentifier=titleName;
func.roomMemberMode=RMM_ANY_PLAYABLE;
bool roomIsFromServer=pparams[0].GetBool();
double roomGuid=pparams[1].GetNumber();
if (roomIsFromServer)
{
// See RoomTypes.h for other default columns
func.query.AddQuery_NUMERIC( DefaultRoomColumns::GetColumnName(DefaultRoomColumns::TC_ROOM_ID), roomGuid);
roomsPlugin->ExecuteFunc(&func);
}
else
{
SystemAddress sa;
sa.FromString(pparams[2].GetString());
char ipPart[32];
sa.ToString(false,ipPart);
rakPeer->Connect(ipPart,sa.GetPort(),0,0);
}
}
示例10: ResponsePeerConnect
//-------------------------------------------------------------------------------------
void UDPClientOnRakNet::ResponsePeerConnect(Packet* p)
{
char buf[512]={0};
tostringstream Log_Info;
char cond=raknet_wrapper::ID_IGT_CLIENT;
memcpy(buf,(void *)(&cond),sizeof(char));
int nSendLength=0;
SystemAddress PeerSysAddr;
P2P_COMMAND::CCmdHandshake * pCmd=new P2P_COMMAND::CCmdHandshake();
PeerSysAddr=p->systemAddress;
Log_Info.str(_T(""));
Log_Info<<"响应Peer连接发送握手包 客户端外部IP:"<<PeerSysAddr.ToString()<<_T("\r\n");
LOG(Log_Debug,Log_Info.str().c_str());
pCmd->m_nSessionID=m_client_sessionID;
nSendLength=0;
if ( pCmd->Create(buf+sizeof(char),nSendLength ) > 0 )
{
Send(buf, (const int) nSendLength+sizeof(char),HIGH_PRIORITY, RELIABLE_ORDERED,0,PeerSysAddr,false);
}
delete pCmd;
}
示例11: OnForwardingSuccess
void CDemo::OnForwardingSuccess(const char *proxyIPAddress, unsigned short proxyPort,
SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin)
{
RakNet::RakString targetName = targetAddress.ToString();
PushMessage(RakNet::RakString("Proxy forwarding to ") + targetName + RakNet::RakString(" through %s:%i succeeded. Connecting.", proxyIPAddress, proxyPort));
rakPeer->Connect(proxyIPAddress, proxyPort,0,0);
}
示例12: ConnectToPlayer
bool Network::ConnectToPlayer( SystemAddress host )
{
ConnectionAttemptResult result = mp_peer->Connect(host.ToString(false), host.port, 0, 0);
switch (result)
{
case CONNECTION_ATTEMPT_STARTED:
cout << "Connected to player" << endl;
return true;
break;
case INVALID_PARAMETER:
cout << "invalid parameter when connecting to peer" << endl;
break;
case CANNOT_RESOLVE_DOMAIN_NAME:
cout << "can not resolve the domain in in connection attempt." << endl;
break;
case ALREADY_CONNECTED_TO_ENDPOINT:
cout << "already connected to peer" << endl;
break;
case CONNECTION_ATTEMPT_ALREADY_IN_PROGRESS:
cout << "already attempting to connect to peer" << endl;
break;
case SECURITY_INITIALIZATION_FAILED:
cout << "no security, very insecure" << endl;
break;
}
return false;
}
示例13: DetectNATType
void NatTypeDetectionClient::DetectNATType(SystemAddress _serverAddress)
{
if (IsInProgress())
return;
if (c2==INVALID_SOCKET)
{
DataStructures::List<RakNetSmartPtr<RakNetSocket> > sockets;
rakPeerInterface->GetSockets(sockets);
SystemAddress sockAddr;
SocketLayer::GetSystemAddress(sockets[0]->s, &sockAddr);
char str[64];
sockAddr.ToString(false,str);
c2=CreateNonblockingBoundSocket(str
#ifdef __native_client__
, sockets[0]->chromeInstance
#endif
);
c2Port=SocketLayer::GetLocalPort(c2);
}
serverAddress=_serverAddress;
RakNet::BitStream bs;
bs.Write((unsigned char)ID_NAT_TYPE_DETECTION_REQUEST);
bs.Write(true); // IsRequest
bs.Write(c2Port);
rakPeerInterface->Send(&bs,MEDIUM_PRIORITY,RELIABLE,0,serverAddress,false);
}
示例14: unregisterInstance
void InstancesTable::unregisterInstance(SystemAddress addr){
std::stringstream str;
str << "DELETE FROM `instances` WHERE `server_address` = '" << addr.ToString() << "');";
auto qr = Database::Query(str.str());
if (qr == NULL){
std::cout << "[ACDB] [MYSQL] " << mysql_error(Database::getConnection()) << std::endl;
}
}
示例15: OnFilePushesComplete
void FLP_Printf::OnFilePushesComplete( SystemAddress systemAddress, unsigned short setID )
{
(void) setID;
char str[32];
systemAddress.ToString(true, (char*) str);
RAKNET_DEBUG_PRINTF("File pushes complete to %s\n", str);
}