diff --git a/Makefile.am b/Makefile.am index c7a80c23d..602264cc1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -163,6 +163,7 @@ include_bitcoin_node_channels_HEADERS = \ include/bitcoin/node/channels/channel_http.hpp \ include/bitcoin/node/channels/channel_peer.hpp \ include/bitcoin/node/channels/channel_tcp.hpp \ + include/bitcoin/node/channels/channel_websocket.hpp \ include/bitcoin/node/channels/channels.hpp include_bitcoin_node_chasersdir = ${includedir}/bitcoin/node/chasers diff --git a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj index b2a222665..6b3f15912 100644 --- a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj @@ -170,6 +170,7 @@ + diff --git a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters index a5623ca7f..6306a2c66 100644 --- a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters +++ b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters @@ -197,6 +197,9 @@ include\bitcoin\node\channels + + include\bitcoin\node\channels + include\bitcoin\node\channels diff --git a/include/bitcoin/node.hpp b/include/bitcoin/node.hpp index 55822b28e..3c0c4bec9 100644 --- a/include/bitcoin/node.hpp +++ b/include/bitcoin/node.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/include/bitcoin/node/channels/channel_websocket.hpp b/include/bitcoin/node/channels/channel_websocket.hpp new file mode 100644 index 000000000..70974e197 --- /dev/null +++ b/include/bitcoin/node/channels/channel_websocket.hpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#ifndef LIBBITCOIN_NODE_CHANNELS_CHANNEL_WEBSOCKET_HPP +#define LIBBITCOIN_NODE_CHANNELS_CHANNEL_WEBSOCKET_HPP + +#include +#include +#include +#include + +namespace libbitcoin { +namespace node { + +/// Abstract base websocket channel state for the node. +class BCN_API channel_websocket + : public network::channel_websocket, + public node::channel +{ +public: + typedef std::shared_ptr ptr; + using options_t = network::channel_websocket::options_t; + + channel_websocket(const network::logger& log, + const network::socket::ptr& socket, + const node::configuration& config, uint64_t identifier=zero, + const options_t& options={}) NOEXCEPT + : network::channel_websocket(log, socket, config.network, identifier, + options), + node::channel(log, socket, config, identifier) + { + } +}; + +} // namespace node +} // namespace libbitcoin + +#endif diff --git a/include/bitcoin/node/channels/channels.hpp b/include/bitcoin/node/channels/channels.hpp index fc22e756a..4909f7d51 100644 --- a/include/bitcoin/node/channels/channels.hpp +++ b/include/bitcoin/node/channels/channels.hpp @@ -23,7 +23,7 @@ #include #include #include -// add channel_websocket to network and derive here +#include #endif diff --git a/include/bitcoin/node/protocols/protocol_websocket.hpp b/include/bitcoin/node/protocols/protocol_websocket.hpp index cfb0825fa..90b5e4e7a 100644 --- a/include/bitcoin/node/protocols/protocol_websocket.hpp +++ b/include/bitcoin/node/protocols/protocol_websocket.hpp @@ -26,6 +26,8 @@ namespace libbitcoin { namespace node { +// TODO: maybe make this an intermediate base class for websockets. +// TODO: and then create a distinct concrete class for deployment. class BCN_API protocol_websocket : public node::protocol_http, protected network::tracker @@ -33,6 +35,9 @@ class BCN_API protocol_websocket public: typedef std::shared_ptr ptr; + // Replace base class channel_t (node::channel_http). + using channel_t = node::channel_websocket; + protocol_websocket(const auto& session, const network::channel::ptr& channel, const options_t& options) NOEXCEPT diff --git a/include/bitcoin/node/settings.hpp b/include/bitcoin/node/settings.hpp index b49e233a5..5e7e74304 100644 --- a/include/bitcoin/node/settings.hpp +++ b/include/bitcoin/node/settings.hpp @@ -136,7 +136,7 @@ class BCN_API settings server::settings::html_server explore{ "explore" }; /// native websocket query interface (http/s->tcp/s, json, handshake) - network::settings::webs_server websocket{ "websocket" }; + network::settings::websocket_server websocket{ "websocket" }; /// bitcoind compat interface (http/s, stateless json-rpc-v2) network::settings::http_server bitcoind{ "bitcoind" };