yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
network_factory.cc
Go to the documentation of this file.
2
3#ifdef __EMSCRIPTEN__
6#else
9#endif
10
11namespace yaze {
12namespace net {
13
14std::unique_ptr<IHttpClient> CreateHttpClient() {
15#ifdef __EMSCRIPTEN__
16 return std::make_unique<EmscriptenHttpClient>();
17#else
18 return std::make_unique<HttpLibClient>();
19#endif
20}
21
22std::unique_ptr<IWebSocket> CreateWebSocket() {
23#ifdef __EMSCRIPTEN__
24 return std::make_unique<EmscriptenWebSocket>();
25#else
26 return std::make_unique<HttpLibWebSocket>();
27#endif
28}
29
31#ifdef __EMSCRIPTEN__
32 // WASM in browser always supports SSL/TLS through browser APIs
33 return true;
34#else
35 // Native builds depend on OpenSSL availability
36 #ifdef CPPHTTPLIB_OPENSSL_SUPPORT
37 return true;
38 #else
39 return false;
40 #endif
41#endif
42}
43
44std::string GetNetworkPlatform() {
45#ifdef __EMSCRIPTEN__
46 return "wasm";
47#else
48 return "native";
49#endif
50}
51
52} // namespace net
53} // namespace yaze
std::string GetNetworkPlatform()
Get the platform name for debugging.
bool IsSSLSupported()
Check if the current platform supports SSL/TLS.
std::unique_ptr< IWebSocket > CreateWebSocket()
Create a WebSocket client for the current platform.
std::unique_ptr< IHttpClient > CreateHttpClient()
Factory functions for creating network clients.