MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / InitializeSockets

Function InitializeSockets

samples/application/chat/main.cpp:118–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116int InitializeChat();
117
118int InitializeSockets()
119{
120 // Initialize library, with the desired local identity
121 g_logTimeZero = SteamNetworkingUtils()->GetLocalTimestamp();
122 SteamNetworkingUtils()->SetDebugOutputFunction(k_ESteamNetworkingSocketsDebugOutputType_Debug, DebugOutput);
123 SteamNetworkingUtils()->SetGlobalConfigValueInt32(k_ESteamNetworkingConfig_LogLevel_P2PRendezvous, k_ESteamNetworkingSocketsDebugOutputType_Debug);
124 SteamDatagramErrMsg errMsg;
125 if (!GameNetworkingSockets_Init(nullptr, errMsg))
126 {
127 SKR_LOG_FATAL(u8"GameNetworkingSockets_Init failed. %s", errMsg);
128 return 1;
129 }
130
131 const char* turnList = "turn:benzzzx.ticp.io:3478";
132 // Hardcode STUN servers
133 SteamNetworkingUtils()->SetGlobalConfigValueString(k_ESteamNetworkingConfig_P2P_STUN_ServerList, "stun:benzzzx.ticp.io:3478");
134
135 // Hardcode TURN servers
136 // comma seperated setting lists
137 const char* userList = "admin";
138 const char* passList = "aaa";
139
140 SteamNetworkingUtils()->SetGlobalConfigValueString(k_ESteamNetworkingConfig_P2P_TURN_ServerList, turnList);
141 SteamNetworkingUtils()->SetGlobalConfigValueString(k_ESteamNetworkingConfig_P2P_TURN_UserList, userList);
142 SteamNetworkingUtils()->SetGlobalConfigValueString(k_ESteamNetworkingConfig_P2P_TURN_PassList, passList);
143
144 // Allow sharing of any kind of ICE address.
145 // We don't have any method of relaying (TURN) in this example, so we are essentially
146 // forced to disclose our public address if we want to pierce NAT. But if we
147 // had relay fallback, or if we only wanted to connect on the LAN, we could restrict
148 // to only sharing private addresses.
149 SteamNetworkingUtils()->SetGlobalConfigValueInt32(k_ESteamNetworkingConfig_P2P_Transport_ICE_Enable, k_nSteamNetworkingConfig_P2P_Transport_ICE_Enable_All);
150
151 return 0;
152}
153
154void read_bytes(skr_vfs_t* vfs, const char* file_name, uint8_t** bytes, uint32_t* length)
155{

Callers 1

initializeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected