adding in examples of headers and origin

This commit is contained in:
talksik
2024-03-30 08:30:39 -07:00
parent f7659c5764
commit 836d202276
2 changed files with 9 additions and 2 deletions
+5 -1
View File
@@ -25,7 +25,11 @@ int main()
}
#endif
std::unique_ptr<WebSocket> ws(WebSocket::from_url("ws://localhost:8126/foo"));
std::map<std::string, std::string> headers;
headers.insert(std::make_pair("Authorization", "Bearer 123"));
std::string origin = "https://example.com";
std::unique_ptr<WebSocket> ws(WebSocket::from_url("ws://localhost:8126/foo", origin, headers));
assert(ws);
ws->send("goodbye");
ws->send("hello");
+4 -1
View File
@@ -29,8 +29,11 @@ int main()
return 1;
}
#endif
std::map<std::string, std::string> headers;
headers.insert(std::make_pair("Authorization", "Bearer 123"));
std::string origin = "https://example.com";
ws = WebSocket::from_url("ws://localhost:8126/foo");
ws = WebSocket::from_url("ws://localhost:8126/foo", origin, headers);
assert(ws);
ws->send("goodbye");
ws->send("hello");