C++17 WebSocket server library
Yes.
Maybe.
Mostly. There's no UTF-8 validation. Everything else should be spec compliant.
Copy the source files into your project, I don't like making libraries.
Create a server:
ws28::Server server{uv_default_loop(), SSL_CTX* or nullptr};
Note: if you have a secure server, it'll actually listen for both secure and insecure connections on that same port by sniffing the first byte. This allows you to run insecure websocket servers on port 443 and not deal with the swarm of broken proxies out there.
Set up some callbacks
See src/Server.h
. But basically, you need some or all of these methods from ws28::Server
: SetClientConnectedCallback
, SetClientDisconnectedCallback
, SetClientDataCallback
, SetCheckConnectionCallback
and SetHTTPCallback
.
Listen
server.Listen(port);
You can also check echo.cpp
for an echo server implementation.
Most files are MIT. The base64 code is BSD, feel free to pull request some MIT licensed code to replace it.
ws28::Client
?Only between ClientConnected and ClientDisconnected callbacks for each client. It is deleted immediately after ClientDisconnected.