|
Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
|
WebSocket room management and broadcast based on MQ. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <uv.h>#include "csilk/core/internal.h"#include "csilk/csilk.h"
Data Structures | |
| struct | ws_room_t |
| struct | ws_room_manager_t |
Functions | |
| static void | ws_room_manager_init () |
| static ws_room_t * | find_room (const char *name) |
| static void | on_room_message (csilk_mq_ctx_t *ctx) |
| void | csilk_ws_join_room (csilk_ctx_t *c, const char *room_name) |
| Join a WebSocket client to a room. | |
| void | csilk_ws_leave_room (csilk_ctx_t *c, const char *room_name) |
| Remove a WebSocket client from a room. | |
| void | csilk_ws_broadcast_room (csilk_ctx_t *c, const char *room_name, const char *message) |
| Broadcast a message to all WebSockets in a room via MQ. | |
Variables | |
| static ws_room_manager_t | g_room_manager |
| static int | g_room_manager_initialized = 0 |
WebSocket room management and broadcast based on MQ.
Implements a high-concurrency room broadcasting system for WebSockets. It leverages the internal Message Queue (MQ) as the event bus.
Architecture:
| struct ws_room_t |
| struct ws_room_manager_t |
| void csilk_ws_broadcast_room | ( | csilk_ctx_t * | c, |
| const char * | room_name, | ||
| const char * | message | ||
| ) |
Broadcast a message to all WebSockets in a room via MQ.
| c | Request context (used to access the server's MQ). |
| room_name | Room to broadcast to. |
| message | NUL-terminated message string. |
| void csilk_ws_join_room | ( | csilk_ctx_t * | c, |
| const char * | room_name | ||
| ) |
Join a WebSocket client to a room.
| c | Request context (must be a WebSocket). |
| room_name | Name of the room to join. |
| void csilk_ws_leave_room | ( | csilk_ctx_t * | c, |
| const char * | room_name | ||
| ) |
Remove a WebSocket client from a room.
| c | Request context. |
| room_name | Name of the room to leave. |
|
static |
|
static |
|
static |
|
static |
|
static |