Update README.md
This commit is contained in:
@@ -2,27 +2,29 @@
|
|||||||
|
|
||||||
µWS ("[micro](https://en.wikipedia.org/wiki/Micro-)WS") 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.
|
µWS ("[micro](https://en.wikipedia.org/wiki/Micro-)WS") 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.
|
||||||
|
|
||||||
|
µWS v0.15 is about 20% faster than v0.14 for small sends, 260% faster for large sends (50 MB).
|
||||||
|
|
||||||
#### Build optimized WebSocket & HTTP servers & clients in no time.
|
#### Build optimized WebSocket & HTTP servers & clients in no time.
|
||||||
```c++
|
```c++
|
||||||
uWS::App a; // or uWS::SSLApp(options) for SSL
|
uWS::App a; // or uWS::SSLApp(options) for SSL
|
||||||
|
|
||||||
a.get("/", [](auto *s, auto *req, auto *args) {
|
a.onGet("/", [](auto *s, auto *req, auto *args) {
|
||||||
|
|
||||||
s->writeStatus(200)->writeHeader("Hello", "World")->end(buffer, 512);
|
s->writeStatus(200)->writeHeader("Hello", "World")->end(buffer, 512);
|
||||||
|
|
||||||
}).get("/largefile", [](auto *s, auto *req, auto *args) {
|
}).onGet("/largefile", [](auto *s, auto *req, auto *args) {
|
||||||
|
|
||||||
s->write([](int offset) {
|
s->write([](int offset) {
|
||||||
// stream chunks of the large file
|
// stream chunks of the large file
|
||||||
}, fileSize);
|
}, fileSize);
|
||||||
|
|
||||||
}).post("/upload/:filename", [](auto *s, auto *req, auto *args) {
|
}).onPost("/upload/:filename", [](auto *s, auto *req, auto *args) {
|
||||||
|
|
||||||
s->read([std::string filename = args[0]](int offset, auto chunk) {
|
s->read([std::string filename = args[0]](int offset, auto chunk) {
|
||||||
// stream chunks of data in to database with filename
|
// stream chunks of data in to database with filename
|
||||||
});
|
});
|
||||||
|
|
||||||
}).websocket("/wsApi", [](auto *protocol) {
|
}).onWebSocket("/wsApi", [](auto *protocol) {
|
||||||
|
|
||||||
protocol->onConnection([](auto *ws) {
|
protocol->onConnection([](auto *ws) {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user