@@ -22,37 +22,29 @@ Extendable
2222<li >
2323Latest standards: c++ 17
2424</li >
25+ <li >
26+ All functions are thread-safe and can be called from any thread at any time
27+ </li >
2528</ul >
2629<h2 >USAGE</h2 >
2730<p >To get started check out the example here<p >
2831https://github.com/smasherprog/websocket_lite/blob/master/Test/main.cpp
2932
3033```
31- SL::WS_LITE::PortNumber port(3001);
32- SL::WS_LITE::WSContext listenerctx(SL::WS_LITE::ThreadCount(1));
33- auto listener = listenerctx.CreateListener(port);
34- listener.onHttpUpgrade([&](const SL::WS_LITE::WSocket& socket) {
35-
36- });
37- listener.onConnection([&](const SL::WS_LITE::WSocket& socket, const std::unordered_map<std::string, std::string>& header) {
38-
39- });
40- listener.onMessage([&](const SL::WS_LITE::WSocket& socket, const SL::WS_LITE::WSMessage& message) {
41-
42- });
34+ auto listener = SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
35+ .CreateListener(SL::WS_LITE::PortNumber(3000))
36+ .onConnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket>& socket, const std::unordered_map<std::string, std::string>& header) {
37+
38+ }).onMessage([&](const std::shared_ptr<SL::WS_LITE::IWSocket>& socket, const SL::WS_LITE::WSMessage& message) {
4339
44- listener.startlistening();
45- SL::WS_LITE::WSContext clientctx(SL::WS_LITE::ThreadCount(1));
46- auto client = clientctx.CreateClient();
47- client.onHttpUpgrade([&](const SL::WS_LITE::WSocket& socket) {
48-
49- });
50- client.onConnection([&](const SL::WS_LITE::WSocket& socket, const std::unordered_map<std::string, std::string>& header) {
40+ }).listen();
5141
52- });
53- client.onDisconnection([&](const SL::WS_LITE::WSocket& socket, unsigned short code, const std::string& msg) {
54-
55- });
56- client.connect("localhost", port);
42+ auto clientctx = SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
43+ .CreateClient()
44+ .onConnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket>& socket, const std::unordered_map<std::string, std::string>& header) {
45+
46+ }).onDisconnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket>& socket, unsigned short code, const std::string& msg) {
47+
48+ }).connect("localhost", SL::WS_LITE::PortNumber(3000));
5749
5850```
0 commit comments