compat.uwebsockets
uWebSockets: header-only HTTP/WebSocket server (libuv backend, no SSL, no zlib)
mcpp add compat.uwebsockets@20.79.0
用法
來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。
// Behavioral test: instantiate the server templates and bind a real port.
//
// The risk in a header-only package layered on a C library is not "does the
// header exist" — it is whether the templates instantiate over the C types as
// the library was actually built, which only the CONSUMER's compile can answer.
// Registering routes instantiates HttpContext/HttpResponse/HttpRequest over
// us_socket_t, and `listen` walks all the way down to a bound socket.
#include <App.h>
#include <cassert>
#include <string>
int main() {
bool bound = false;
int chosen_port = 0;
uWS::App app;
// Two route shapes and a websocket behavior: each instantiates a different
// corner of the template stack.
app.get("/ping", [](auto* res, auto* /*req*/) {
res->end("pong");
// …
tests/examples/uwebsockets/tests/listen.cpp · 專案 tests/examples/uwebsockets
建置
- targets
uWebSockets (lib)- language
c++23- C standard
c11- import std
- no
- include dirs
*/src
原始檔 (1)
mcpp_generated/uws_anchor.c
產生的檔案
mcpp_generated/uws_anchor.c