Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/waqqas/websocketer
A header-only websocket client library build on Boost::Beast
https://github.com/waqqas/websocketer
Last synced: 2 months ago
JSON representation
A header-only websocket client library build on Boost::Beast
- Host: GitHub
- URL: https://github.com/waqqas/websocketer
- Owner: waqqas
- License: bsd-3-clause
- Created: 2021-01-27T18:02:13.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-15T05:55:08.000Z (almost 4 years ago)
- Last Synced: 2023-08-12T13:59:01.656Z (over 1 year ago)
- Language: C++
- Size: 57.6 KB
- Stars: 4
- Watchers: 2
- Forks: 4
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Websocketer
A header-only websocket client library built on boost::beast library
Dependencies
---- Boost (1.75 or greater)
- OpenSSL
- Google Benchmark (for benchmarks)Building on OSX
---- `mkdir build`
- `cd build`
- ```cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DCMAKE_INSTALL_PREFIX:PATH=`pwd`/usr ..```
- `cmake --build . --config Release --target install -- -j $(nproc)`Running tests
---- `./tests/tests`
Usage
---Steps
```
#include "websocketer/websocketer.hpp"#include
#include
#includeTEST_CASE("ws")
{
namespace beast = boost::beast;
namespace ws = websocketer::asio;bool passed = false;
std::string host("echo.websocket.org");
std::string service("80");boost::asio::io_context io;
ws::ws client(io, host, service);
beast::flat_buffer buffer;
std::string data_to_send("hello world");client.async_open([&data_to_send, &buffer, &passed](const boost::system::error_code &ec,
std::shared_ptr socket) {
if (!ec)
{
socket->async_write(data_to_send, [&buffer, &passed](const boost::system::error_code &ec,
std::shared_ptr socket,
std::size_t) {
if (!ec)
{
socket->async_read(buffer, [&passed](const boost::system::error_code &ec,
std::shared_ptr socket, std::size_t) {
if (!ec)
{
socket->async_close(
[&](const boost::system::error_code &ec, std::shared_ptr) {
if (!ec)
{
passed = true;
}
});}
});
}
});
}
});io.run();
REQUIRE(passed);
}```