From b40937cea80d674fa67e50c3690b6b5056f05d47 Mon Sep 17 00:00:00 2001 From: yhirose Date: Sat, 11 Jul 2026 14:12:25 -0400 Subject: [PATCH] Fix README WebSocket example to match actual API (Fix #2493) The quick preview used a nonexistent httplib::ws::Message type with .is_text()/.data. The actual API, as shown in README-websocket.md, uses a plain std::string with ws.read(msg). --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 962f87a..9a6bebb 100644 --- a/README.md +++ b/README.md @@ -1490,11 +1490,9 @@ See [README-sse.md](README-sse.md) for more details. httplib::Server svr; svr.WebSocket("/ws", [](const httplib::Request &req, httplib::ws::WebSocket &ws) { - httplib::ws::Message msg; + std::string msg; while (ws.read(msg)) { - if (msg.is_text()) { - ws.send("Echo: " + msg.data); - } + ws.send("Echo: " + msg); } });