Skip to content

Commit 279dc37

Browse files
authored
Update README.md
1 parent b6fd275 commit 279dc37

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

README.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,31 +28,20 @@ Latest standards: c++ 17
2828
https://github.com/smasherprog/websocket_lite/blob/master/Test/main.cpp
2929

3030
```
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-
});
31+
auto listener = SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
32+
.CreateListener(SL::WS_LITE::PortNumber(3000))
33+
.onConnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket>& socket, const std::unordered_map<std::string, std::string>& header) {
34+
35+
}).onMessage([&](const std::shared_ptr<SL::WS_LITE::IWSocket>& socket, const SL::WS_LITE::WSMessage& message) {
4336
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) {
37+
}).listen();
4838
49-
});
50-
client.onConnection([&](const SL::WS_LITE::WSocket& socket, const std::unordered_map<std::string, std::string>& header) {
51-
52-
});
53-
client.onDisconnection([&](const SL::WS_LITE::WSocket& socket, unsigned short code, const std::string& msg) {
54-
55-
});
56-
client.connect("localhost", port);
39+
auto clientctx = SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
40+
.CreateClient()
41+
.onConnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket>& socket, const std::unordered_map<std::string, std::string>& header) {
42+
43+
}).onDisconnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket>& socket, unsigned short code, const std::string& msg) {
44+
45+
}).connect("localhost", SL::WS_LITE::PortNumber(3000));
5746
5847
```

0 commit comments

Comments
 (0)