@@ -42,20 +42,29 @@ WIndows: vcpkg install openssl zlib
4242https://github.com/smasherprog/websocket_lite/blob/master/Test/main.cpp
4343
4444``` c++
45- auto listener = SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1 ))
46- .CreateListener(SL::WS_LITE::PortNumber(3000 ))
47- .onConnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket>& socket, const std::unordered_map<std::string, std::string>& header) {
48-
49- }).onMessage([ &] (const std::shared_ptr< SL::WS_LITE::IWSocket > & socket, const SL::WS_LITE::WSMessage& message) {
5045
51- }).listen();
46+ SL::WS_LITE::PortNumber port (3002);
47+ auto listener =
48+ SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
49+ ->NoTLS()
50+ ->CreateListener(port)
51+ ->onConnection([ &] (const std::shared_ptr< SL::WS_LITE::IWSocket > &socket, const std::unordered_map<std::string, std::string> &header) {
52+
53+ })
54+ ->onMessage([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, const SL::WS_LITE::WSMessage &message) {
55+
56+ })->listen();
57+ listener->set_ReadTimeout(std::chrono::seconds(100));
58+ listener->set_WriteTimeout(std::chrono::seconds(100));
5259
53- auto clientctx = SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
54- .CreateClient( )
55- .onConnection( [ & ] (const std::shared_ptr < SL::WS_LITE::IWSocket > & socket, const std::unordered_map<std::string, std::string>& header) {
56-
57- }).onDisconnection ([ &] (const std::shared_ptr< SL::WS_LITE::IWSocket > & socket, unsigned short code, const std::string& msg ) {
60+ auto clientctx =
61+ SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1) )
62+ ->NoTLS()
63+ ->CreateClient()
64+ ->onConnection ([ &] (const std::shared_ptr< SL::WS_LITE::IWSocket > & socket, const std::unordered_map<std::string, std::string> &header ) {
5865
59- }).connect("localhost", SL::WS_LITE::PortNumber(3000));
66+ })
67+ ->onDisconnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, unsigned short code, const std::string &msg) {
68+ })->connect("localhost", port);
6069
6170```
0 commit comments