a2fe871e6338cbb8a675eb478cdf2b30eef8250d
v0.15 of µWebSockets
µWS ("microWS") is a modern C++17 implementation of WebSockets & HTTP. It focuses on performance & memory usage and has been shown to outperform Node.js v10 some 13x (8x with SSL) while still being just as easy to work with.
Build optimized WebSocket & HTTP servers & clients in no time.
uWS::App a; // or uWS::SSLApp(options) for SSL
a.get("/", [](auto *s, auto *req, auto *args) {
s->writeStatus(200)->writeHeader("Hello", "World")->end(buffer, 512);
}).get("/largefile", [](auto *s, auto *req, auto *args) {
s->write([](int offset) {
// stream chunks of the large file
}, fileSize);
}).post("/upload/:filename", [](auto *s, auto *req, auto *args) {
s->read([std::string filename = args[0]](int offset, auto chunk) {
// stream chunks of data in to database with filename
});
}).websocket("/wsApi", [](auto *protocol) {
protocol->onConnection([](auto *ws) {
// store this websocket somewhere
})->onMessage([](auto *ws, auto message, auto opCode) {
ws->send(message, opCode);
})->onDisconnection([]() {
// remove this websocket
});
}).listen("localhost", 3000, 0);
Languages
C++
81.9%
C
14.2%
Rust
1.8%
Makefile
1.4%
JavaScript
0.7%