MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / AddressToString

Method AddressToString

Sources/Jazz2/Multiplayer/NetworkManagerBase.cpp:809–827  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

807
808
809 String NetworkManagerBase::AddressToString(const struct in_addr& address, std::uint16_t port)
810 {
811#if defined(DEATH_TARGET_EMSCRIPTEN) && defined(WITH_WEBSOCKET)
812 // TODO: Implement this properly on Emscripten
813 return {};
814#else
815 char addressString[64];
816
817 if (inet_ntop(AF_INET, &address, addressString, sizeof(addressString) - 1) == NULL) {
818 return {};
819 }
820
821 std::size_t addressLength = strnlen(addressString, sizeof(addressString));
822 if (port != 0) {
823 addressLength = addressLength + formatInto({ &addressString[addressLength], sizeof(addressString) - addressLength }, ":{}", port);
824 }
825 return String(addressString, addressLength);
826#endif
827 }
828
829#if ENET_IPV6
830 String NetworkManagerBase::AddressToString(const struct in6_addr& address, std::uint16_t scopeId, std::uint16_t port)

Callers 5

OnPeerConnectedMethod · 0.80
OnPeerDisconnectedMethod · 0.80
OnPacketReceivedMethod · 0.80
OnClientThreadMethod · 0.80
ProcessCommandMethod · 0.80

Calls 9

formatIntoFunction · 0.85
enet_inaddr_map6to4Function · 0.85
ExtractHostFromWsUrlFunction · 0.85
DEATH_UNLIKELYFunction · 0.70
DEATH_LIKELYFunction · 0.70
inet_ntopFunction · 0.50
StringClass · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected