From 806eed60401f948bfb5466b601deae1ff4dd8d48 Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Thu, 21 Jul 2022 11:46:50 -0300 Subject: [PATCH] Add mg_ws_printf()/vprintf() doc --- docs/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/README.md b/docs/README.md index 7b2e39db..d8ae81ab 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1498,6 +1498,32 @@ void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) { } ``` +### mg\_ws\_printf(), mg\_ws\_vprintf() + +```c +size_t mg_ws_printf(struct mg_connection *, int op, const char *fmt, ...); +size_t mg_ws_vprintf(struct mg_connection *, int op, const char *fmt, va_list); +``` + +Same as `mg_ws_send()`, but formats data using `printf()` semantics. +NOTE: See [mg\_ws\_send](#mg_ws_send) +for the list of possible Websocket message types +NOTE: See [mg\_snprintf](#mg_snprintf-mg_vsnprintf) +for the list of supported format specifiers + +Parameters: +- `c` - Connection to use +- `op` - Websocket message type +- `fmt` - format string in `printf` semantics + +Return value: sent bytes count + +Usage example: + +```c +mg_ws_printf(c, WEBSOCKET_OP_TEXT, "Hello, %s!", "world"); +``` + ### mg\_ws\_wrap() ```c