From 74506169d6398e97a33e683acf0882cca85b235c Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Tue, 20 Oct 2026 18:27:11 +0300
Subject: [PATCH 88/88] emscripten: Make communication with the server to work

See RM #2389

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/gui-sdl2/gui_main.c | 8 ++++++++
 client/gui-sdl3/gui_main.c | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/client/gui-sdl2/gui_main.c b/client/gui-sdl2/gui_main.c
index a7f9879e5c..4041b03116 100644
--- a/client/gui-sdl2/gui_main.c
+++ b/client/gui-sdl2/gui_main.c
@@ -651,11 +651,19 @@ widget_id gui_event_loop(void *data,
           continue;
         }
       } else {
+
+#ifdef __EMSCRIPTEN__
+        if (net_socket >= 0) {
+          SDL_PushEvent(net_user_event);
+        }
+#else  /* __EMSCRIPTEN__ */
         if (result > 0) {
           if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
             SDL_PushEvent(net_user_event);
           }
         }
+#endif /* __EMSCRIPTEN__ */
+
       }
     } else { /* If connection is not establish */
       SDL_Delay(10);
diff --git a/client/gui-sdl3/gui_main.c b/client/gui-sdl3/gui_main.c
index 3df7b6048f..c94f324514 100644
--- a/client/gui-sdl3/gui_main.c
+++ b/client/gui-sdl3/gui_main.c
@@ -644,11 +644,19 @@ widget_id gui_event_loop(void *data,
           continue;
         }
       } else {
+
+#ifdef __EMSCRIPTEN__
+        if (net_socket >= 0) {
+          SDL_PushEvent(net_user_event);
+        }
+#else  /* __EMSCRIPTEN__ */
         if (result > 0) {
           if ((net_socket >= 0) && FD_ISSET(net_socket, &civfdset)) {
             SDL_PushEvent(net_user_event);
           }
         }
+#endif /* __EMSCRIPTEN__ */
+
       }
     } else { /* If connection is not establish */
       SDL_Delay(10);
-- 
2.53.0

