This library is a fully compliant websocket implementation! Autobahn complete , but with a few design goals:
- Cross-platform: Asio https://github.com/chriskohlhoff/asio/
- Performance
- Simple and easy to use
- Latest standards: c++ 17
- All functions are thread-safe and can be called from any thread at any time
- Ubuntu: sudo apt-get install libssl-dev zlib1g-dev -y
- Mac: brew install openssl zlib
- WIndows: vcpkg install openssl zlib
To get started check out the example here
https://github.com/smasherprog/websocket_lite/blob/master/Test/main.cpp
SL::WS_LITE::PortNumber port(3002);
auto listener =
SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
->NoTLS()
->CreateListener(port)
->onConnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, const std::unordered_map<std::string, std::string> &header) {
})
->onMessage([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, const SL::WS_LITE::WSMessage &message) {
})->listen();
listener->set_ReadTimeout(std::chrono::seconds(100));
listener->set_WriteTimeout(std::chrono::seconds(100));
auto clientctx =
SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
->NoTLS()
->CreateClient()
->onConnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, const std::unordered_map<std::string, std::string> &header) {
})
->onDisconnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, unsigned short code, const std::string &msg) {
})->connect("localhost", port);