forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocketBridge.cpp
More file actions
32 lines (28 loc) · 825 Bytes
/
SocketBridge.cpp
File metadata and controls
32 lines (28 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "il2cpp-config.h"
#if IL2CPP_TARGET_JAVASCRIPT
#include "os/SocketBridge.h"
#ifdef __EMSCRIPTEN_PTHREADS__
#include <emscripten/threading.h>
#include <emscripten/posix_socket.h>
#endif // __EMSCRIPTEN_PTHREADS__
namespace il2cpp
{
namespace os
{
void SocketBridge::WaitForInitialization()
{
#ifdef __EMSCRIPTEN_PTHREADS__
EMSCRIPTEN_WEBSOCKET_T bridgeSocket = emscripten_init_websocket_to_posix_socket_bridge("ws://localhost:6690");
// Synchronously wait until connection has been established
uint16_t readyState = 0;
do
{
emscripten_websocket_get_ready_state(bridgeSocket, &readyState);
emscripten_thread_sleep(100);
}
while (readyState == 0);
#endif // __EMSCRIPTEN_PTHREADS__
}
}
}
#endif // IL2CPP_TARGET_JAVASCRIPT