I am trying to port a c++ framework to the web. Each Client starts the application in a separate browser window and has to wait for all clients to be connected. The connection/communication between the browser windows is established via WebRTC. The WebRTC channels all work perfectly fine, however the waiting (=emscripten_sleep) somehow takes way longer to than expected.
// wait for all other players to connect
int sleep_interval = 1000;
int time_slept = 0;
while (connected_users < nplayers and time_slept < 60*1000)
{
cout << "connected users(" << connected_users << "/" << nplayers << ")" << endl;
emscripten_sleep(sleep_interval);
time_slept += sleep_interval;
}
if(connected_users < nplayers) {
cerr << "Timeout - only " << connected_users << " clients!" << endl;
exit(-1);
}
cout << "All clients connected!" << endl;
emscripten_websocket_close(websocket_conn, 0, "Finshed WebRTC-Connection establishment.");
emscripten_websocket_delete(websocket_conn);
The output is always different - on one browser tab it works perfectly fine, on the other it just outputs once "connected_users(1/3)" then it outputs nothing for like 2 minutes and then it outputs ("All clients connected"). Even though the debug messages for webrtc have been finished after 2 seconds.
I use -sASYNCIFY.
I am trying to port a c++ framework to the web. Each Client starts the application in a separate browser window and has to wait for all clients to be connected. The connection/communication between the browser windows is established via WebRTC. The WebRTC channels all work perfectly fine, however the waiting (=emscripten_sleep) somehow takes way longer to than expected.
The output is always different - on one browser tab it works perfectly fine, on the other it just outputs once "connected_users(1/3)" then it outputs nothing for like 2 minutes and then it outputs ("All clients connected"). Even though the debug messages for webrtc have been finished after 2 seconds.
I use -sASYNCIFY.