少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
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