Mercurial
comparison seobeo/s_websocket.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 | 058de208e640 |
comparison
equal
deleted
inserted
replaced
| 124:dbf14f84d51c | 125:f236c895604e |
|---|---|
| 188 Seobeo_Log(SEOBEO_INFO, "WebSocket connected to %s\n", url); | 188 Seobeo_Log(SEOBEO_INFO, "WebSocket connected to %s\n", url); |
| 189 | 189 |
| 190 return p_ws; | 190 return p_ws; |
| 191 } | 191 } |
| 192 | 192 |
| 193 static void Seobeo_WebSocket_Mask_Data(uint8 *data, size_t length, const uint8 *mask) | 193 // Seobeo_WebSocket_Mask_Data moved to s_websocket_common.c |
| 194 { | |
| 195 for (size_t i = 0; i < length; i++) | |
| 196 data[i] ^= mask[i % 4]; | |
| 197 } | |
| 198 | 194 |
| 199 static int32 Seobeo_WebSocket_Send_Frame(Seobeo_WebSocket *p_ws, Seobeo_WebSocket_Opcode opcode, | 195 static int32 Seobeo_WebSocket_Send_Frame(Seobeo_WebSocket *p_ws, Seobeo_WebSocket_Opcode opcode, |
| 200 const uint8 *payload, size_t payload_length, boolean fin) | 196 const uint8 *payload, size_t payload_length, boolean fin) |
| 201 { | 197 { |
| 202 if (!p_ws || p_ws->state != SEOBEO_WS_STATE_OPEN) | 198 if (!p_ws || p_ws->state != SEOBEO_WS_STATE_OPEN) |
| 482 p_msg->is_final = fin; | 478 p_msg->is_final = fin; |
| 483 | 479 |
| 484 return p_msg; | 480 return p_msg; |
| 485 } | 481 } |
| 486 | 482 |
| 487 void Seobeo_WebSocket_Message_Destroy(Seobeo_WebSocket_Message *p_msg) | 483 // Seobeo_WebSocket_Message_Destroy moved to s_websocket_common.c |
| 488 { | |
| 489 if (!p_msg) | |
| 490 return; | |
| 491 | |
| 492 if (p_msg->data) | |
| 493 free(p_msg->data); | |
| 494 | |
| 495 free(p_msg); | |
| 496 } | |
| 497 | 484 |
| 498 int32 Seobeo_WebSocket_Close(Seobeo_WebSocket *p_ws, uint16 code, const char *reason) | 485 int32 Seobeo_WebSocket_Close(Seobeo_WebSocket *p_ws, uint16 code, const char *reason) |
| 499 { | 486 { |
| 500 if (!p_ws || p_ws->state == SEOBEO_WS_STATE_CLOSED) | 487 if (!p_ws || p_ws->state == SEOBEO_WS_STATE_CLOSED) |
| 501 return -1; | 488 return -1; |