Mercurial
diff seobeo/s_websocket.c @ 121:7b1719fa918c
[Seobeo] Added web socket server.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Thu, 08 Jan 2026 06:45:10 -0800 |
| parents | cbbf78b17cfa |
| children | f236c895604e |
line wrap: on
line diff
--- a/seobeo/s_websocket.c Thu Jan 08 03:19:59 2026 -0800 +++ b/seobeo/s_websocket.c Thu Jan 08 06:45:10 2026 -0800 @@ -2,8 +2,6 @@ #include <time.h> #define SEOBEO_WS_GUID "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" -#define MAX_INT_16 65536 -#define MAX_INT_64 18446744073709551615 static void Seobeo_WebSocket_Parse_Url(const char *url, char **p_host, char **p_port, char **p_path, boolean *p_use_tls, Dowa_Arena *p_arena) { @@ -256,31 +254,30 @@ return Seobeo_Handle_Flush(p_ws->p_handle); } -static int32 Seobeo_WebSocket_Send_Fragmented(Seobeo_WebSocket *p_ws, Seobeo_WebSocket_Opcode opcode, const uint8 *payload, size_t total_length) +static int32 Seobeo_WebSocket_Send_Fragmented(Seobeo_WebSocket *p_ws, Seobeo_WebSocket_Opcode opcode, + const uint8 *payload, size_t total_length) { if (!payload || total_length == 0) return -1; - const size_t max_fragment_size = 1024 * 1024; - - if (total_length <= max_fragment_size) + if (total_length <= MAX_FRAGMENT_SIZE) return Seobeo_WebSocket_Send_Frame(p_ws, opcode, payload, total_length, TRUE); size_t sent = 0; int32 result; - result = Seobeo_WebSocket_Send_Frame(p_ws, opcode, payload, max_fragment_size, FALSE); + result = Seobeo_WebSocket_Send_Frame(p_ws, opcode, payload, MAX_FRAGMENT_SIZE, FALSE); if (result < 0) return result; - sent += max_fragment_size; + sent += MAX_FRAGMENT_SIZE; - while (sent + max_fragment_size < total_length) + while (sent + MAX_FRAGMENT_SIZE < total_length) { - result = Seobeo_WebSocket_Send_Frame(p_ws, SEOBEO_WS_OPCODE_CONTINUATION, payload + sent, max_fragment_size, FALSE); + result = Seobeo_WebSocket_Send_Frame(p_ws, SEOBEO_WS_OPCODE_CONTINUATION, payload + sent, MAX_FRAGMENT_SIZE, FALSE); if (result < 0) return result; - sent += max_fragment_size; + sent += MAX_FRAGMENT_SIZE; } size_t remaining = total_length - sent;