Skip to content

Commit c2a56b4

Browse files
committed
2 parents e566ace + b85f32e commit c2a56b4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,33 @@ https://github.com/smasherprog/websocket_lite/blob/master/Test/main.cpp
2929

3030
```
3131
32-
auto listener = SL::WS_LITE::WSListener::CreateListener(3002);
33-
listener.onHttpUpgrade([](const SL::WS_LITE::WSocket& socket) {
32+
SL::WS_LITE::ThreadCount thrdcount(1);
33+
SL::WS_LITE::PortNumber port(3002);
34+
auto listener = SL::WS_LITE::WSListener::CreateListener(thrdcount, port);
35+
listener.onHttpUpgrade([&](const SL::WS_LITE::WSocket& socket) {
3436
SL_WS_LITE_LOG(SL::WS_LITE::Logging_Levels::INFO_log_level, "listener::onHttpUpgrade");
3537
});
36-
listener.onConnection([](const SL::WS_LITE::WSocket& socket, const std::unordered_map<std::string, std::string>& header) {
38+
listener.onConnection([&](const SL::WS_LITE::WSocket& socket, const std::unordered_map<std::string, std::string>& header) {
3739
SL_WS_LITE_LOG(SL::WS_LITE::Logging_Levels::INFO_log_level, "listener::onConnection");
40+
3841
});
39-
listener.onDisconnection([](const SL::WS_LITE::WSocket& socket, unsigned short code, const std::string& msg) {
42+
listener.onDisconnection([&](const SL::WS_LITE::WSocket& socket, unsigned short code, const std::string& msg) {
43+
lastheard = std::chrono::high_resolution_clock::now();
4044
SL_WS_LITE_LOG(SL::WS_LITE::Logging_Levels::INFO_log_level, "listener::onDisconnection");
4145
});
4246
listener.startlistening();
4347
44-
auto client = SL::WS_LITE::WSClient::CreateClient();
45-
client.onHttpUpgrade([](const SL::WS_LITE::WSocket& socket) {
48+
auto client = SL::WS_LITE::WSClient::CreateClient(thrdcount);
49+
client.onHttpUpgrade([&](const SL::WS_LITE::WSocket& socket) {
4650
SL_WS_LITE_LOG(SL::WS_LITE::Logging_Levels::INFO_log_level, "Client::onHttpUpgrade");
47-
4851
});
49-
client.onConnection([](const SL::WS_LITE::WSocket& socket, const std::unordered_map<std::string, std::string>& header) {
52+
client.onConnection([&](const SL::WS_LITE::WSocket& socket, const std::unordered_map<std::string, std::string>& header) {
5053
SL_WS_LITE_LOG(SL::WS_LITE::Logging_Levels::INFO_log_level, "Client::onConnection");
5154
});
52-
client.onDisconnection([](const SL::WS_LITE::WSocket& socket, unsigned short code, const std::string& msg) {
55+
client.onDisconnection([&](const SL::WS_LITE::WSocket& socket, unsigned short code, const std::string& msg) {
5356
SL_WS_LITE_LOG(SL::WS_LITE::Logging_Levels::INFO_log_level, "client::onDisconnection");
5457
});
55-
client.connect("localhost", 3002);
58+
client.connect("localhost", port);
5659
5760
5861
```

0 commit comments

Comments
 (0)