diff seobeo/s_websocket_server.c @ 125:f236c895604e

[MrJuneJune] Added web socket for chat to this.
author June Park <parkjune1995@gmail.com>
date Thu, 08 Jan 2026 08:46:49 -0800
parents 7b1719fa918c
children 893d87124d16
line wrap: on
line diff
--- a/seobeo/s_websocket_server.c	Thu Jan 08 07:31:32 2026 -0800
+++ b/seobeo/s_websocket_server.c	Thu Jan 08 08:46:49 2026 -0800
@@ -120,11 +120,7 @@
   return TRUE;
 }
 
-static void Seobeo_WebSocket_Unmask_Data(uint8 *data, size_t length, const uint8 *mask)
-{
-  for (size_t i = 0; i < length; i++)
-    data[i] ^= mask[i % 4];
-}
+// Seobeo_WebSocket_Unmask_Data removed - using Seobeo_WebSocket_Mask_Data from s_websocket_common.c (XOR is symmetric)
 
 static int32 Seobeo_WebSocket_Server_Send_Frame(Seobeo_WebSocket_Server_Connection *p_conn, Seobeo_WebSocket_Opcode opcode, const uint8 *payload, size_t payload_length, boolean fin)
 {
@@ -285,7 +281,7 @@
     memcpy(payload, buf + header_len, payload_len);
 
     if (masked)
-      Seobeo_WebSocket_Unmask_Data(payload, payload_len, mask_key);
+      Seobeo_WebSocket_Mask_Data(payload, payload_len, mask_key);
   }
 
   Seobeo_Handle_Consume(p_conn->p_handle, (uint32)(header_len + payload_len));
@@ -414,7 +410,7 @@
   Seobeo_WebSocket_Server_Connection_Destroy(p_conn);
 }
 
-void Seobeo_WebSocket_Server_Broadcast_Text(const char *text)
+void Seobeo_WebSocket_Server_Broadcast_Text(const char *text, Seobeo_WebSocket_Server_Connection *origin_p_conn)
 {
   if (!text)
     return;
@@ -422,7 +418,7 @@
   Seobeo_WebSocket_Server_Connection *p_conn = g_ws_connections;
   while (p_conn)
   {
-    if (p_conn->is_active)
+    if (p_conn->is_active && p_conn != origin_p_conn)
       Seobeo_WebSocket_Server_Send_Text(p_conn, text);
 
     p_conn = p_conn->next;