Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,13 @@ jobs:
with:
path: ws-io-root

- name: Clone Boost.Http.Io
uses: actions/checkout@v3
with:
repository: cppalliance/http_io
path: http-io-root
ref: develop

- name: Clone Boost.Ws.Proto
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -884,12 +891,14 @@ jobs:
modules-exclude-paths: ''
scan-modules-dir: |
ws-io-root
http-io-root
ws-proto-root
http-proto-root
buffers-root
rts-root
scan-modules-ignore: |
ws_io
http_io
ws_proto
http_proto
buffers
Expand Down Expand Up @@ -961,11 +970,12 @@ jobs:
echo -E "boost_root=$boost_root" >> $GITHUB_OUTPUT

# Patch boost-root with workspace module
cp -r "$workspace_root"/ws-io-root "libs/$module"
cp -r "$workspace_root"/rts-root libs/rts
cp -r "$workspace_root"/buffers-root libs/buffers
cp -r "$workspace_root"/http-proto-root libs/http_proto
cp -r "$workspace_root"/http-io-root libs/http_io
cp -r "$workspace_root"/ws-proto-root libs/ws_proto
cp -r "$workspace_root"/ws-io-root "libs/$module"

- name: Boost B2 Workflow
uses: alandefreitas/cpp-actions/b2-workflow@v1.8.10
Expand Down Expand Up @@ -1179,6 +1189,13 @@ jobs:
with:
path: ws-io-root

- name: Clone Boost.Http.Io
uses: actions/checkout@v3
with:
repository: cppalliance/http_io
path: http-io-root
ref: develop

- name: Clone Boost.WS.Proto
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -1217,12 +1234,14 @@ jobs:
modules-exclude-paths: ''
scan-modules-dir: |
ws-io-root
http-io-root
ws-proto-root
http-proto-root
buffers-root
rts-root
scan-modules-ignore: |
ws_io
http_io
ws_proto
http_proto
buffers
Expand Down Expand Up @@ -1258,10 +1277,11 @@ jobs:
echo -E "boost_root=$boost_root" >> $GITHUB_OUTPUT

# Patch boost-root with workspace module
cp -r "$workspace_root"/ws-io-root "libs/$module"
cp -r "$workspace_root"/rts-root libs/rts
cp -r "$workspace_root"/buffers-root libs/buffers
cp -r "$workspace_root"/http-io-root libs/http_io
cp -r "$workspace_root"/http-proto-root libs/http_proto
cp -r "$workspace_root"/ws-io-root "libs/$module"
cp -r "$workspace_root"/ws-proto-root libs/ws_proto

- uses: actions/setup-node@v4
Expand Down
11 changes: 7 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ set(BOOST_WS_IO_DEPENDENCIES
Boost::system
Boost::url
Boost::ws_proto
Boost::http_io
)

foreach (BOOST_WS_IO_DEPENDENCY ${BOOST_WS_IO_DEPENDENCIES})
Expand Down Expand Up @@ -131,13 +132,15 @@ endif ()
#-------------------------------------------------
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

file(GLOB_RECURSE BOOST_WS_IO_HEADERS CONFIGURE_DEPENDS include/boost/*.hpp include/boost/*.natvis)
file(GLOB_RECURSE BOOST_WS_IO_HEADERS CONFIGURE_DEPENDS include/boost/ws_io/*.hpp include/boost/ws_io/*.natvis)
file(GLOB_RECURSE BOOST_WS_IO_SOURCES CONFIGURE_DEPENDS src/*.cpp src/*.hpp)
file(GLOB_RECURSE BOOST_WS_PROTO_SOURCES CONFIGURE_DEPENDS src/*.cpp src/*.hpp)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include/boost PREFIX "" FILES ${BOOST_WS_IO_HEADERS})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "ws_io" FILES ${BOOST_WS_IO_SOURCES})
source_group("" FILES "include/boost/ws_io.hpp" "build/Jamfile")
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include/boost/ws_io PREFIX "include" FILES ${BOOST_WS_IO_HEADERS})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "src" FILES ${BOOST_WS_IO_SOURCES})

add_library(boost_ws_io ${BOOST_WS_IO_HEADERS} ${BOOST_WS_IO_SOURCES})
add_library(boost_ws_io include/boost/ws_io.hpp build/Jamfile ${BOOST_WS_IO_HEADERS} ${BOOST_WS_IO_SOURCES})
add_library(Boost::ws_io ALIAS boost_ws_io)
target_compile_features(boost_ws_io PUBLIC cxx_constexpr)
target_include_directories(boost_ws_io PUBLIC "${PROJECT_SOURCE_DIR}/include")
Expand Down
2 changes: 2 additions & 0 deletions build/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ lib boost_ws_io
: ws_io_sources
: requirements
<library>/boost//ws_proto
<library>/boost//http_io
: usage-requirements
<library>/boost//ws_proto
<library>/boost//http_io
;

boost-install boost_ws_io ;
113 changes: 113 additions & 0 deletions include/boost/ws_io/client.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//
// Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/ws_io
//

#ifndef BOOST_WS_IO_CLIENT_HPP
#define BOOST_WS_IO_CLIENT_HPP

#include <boost/ws_io/detail/config.hpp>
#include <boost/ws_io/peer.hpp>
#include <boost/ws_proto/client.hpp>
#include <boost/http_proto/response_view.hpp>
#include <boost/http_proto/request.hpp>
#include <boost/asio/async_result.hpp>
#include <boost/asio/default_completion_token.hpp>
#include <boost/buffers/const_buffer.hpp>
#include <boost/core/detail/string_view.hpp>
#include <boost/core/span.hpp>
#include <type_traits>

namespace boost {
namespace ws_io {

struct null_decorator
{
void operator()(...) const noexcept
{
}
};

struct frame
{
ws_proto::frame_type kind;
buffers::const_buffer data;
};

struct read_results
{
span<buffers::const_buffer> messages;
};

//------------------------------------------------

/** A websocket client session
*/
template<
class AsyncStream>
class client : public peer<AsyncStream>
{
public:
template<class AsyncStream_>
client(
AsyncStream_&& stream,
rts::context& ctx)
: peer<AsyncStream>(
std::forward<AsyncStream_>(stream),
ctx)
{
}

/** Perform the websocket handshake
*/
template<
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(
::boost::system::error_code,
::boost::http_proto::response_view)) HandshakeHandler =
asio::default_completion_token_t<executor_type>,
class Decorator = null_decorator
>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(HandshakeHandler, void(
::boost::system::error_code,
::boost::http_proto::response_view))
async_handshake(
core::string_view host,
core::string_view target,
HandshakeHandler&& handler =
asio::default_completion_token_t<executor_type>{},
Decorator decorator = {}
);

/** Write a complete message
*/
template<
class ConstBufferSequence,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(
::boost::system::error_code,
std::size_t)) WriteHandler =
asio::default_completion_token_t<executor_type>
>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(WriteHandler, void(
::boost::system::error_code,
std::size_t))
async_write(
ConstBufferSequence const& data,
WriteHandler&& handler =
asio::default_completion_token_t<executor_type>{}
);

private:
class handshake_op;
template<class> class write_op;
};

} // ws_io
} // boost

#include <boost/ws_io/impl/client.hpp>

#endif
Loading
Loading