Skip to content
Merged
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
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ include_bitcoin_node_protocols_HEADERS = \
include/bitcoin/node/protocols/protocol_transaction_out_106.hpp \
include/bitcoin/node/protocols/protocol_web.hpp \
include/bitcoin/node/protocols/protocol_websocket.hpp \
include/bitcoin/node/protocols/protocol_websocket_handshake.hpp \
include/bitcoin/node/protocols/protocols.hpp

include_bitcoin_node_sessionsdir = ${includedir}/bitcoin/node/sessions
Expand Down
1 change: 1 addition & 0 deletions builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_transaction_out_106.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_web.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_websocket.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_websocket_handshake.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocols.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\sessions\session.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\sessions\session_inbound.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_websocket.hpp">
<Filter>include\bitcoin\node\protocols</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_websocket_handshake.hpp">
<Filter>include\bitcoin\node\protocols</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocols.hpp">
<Filter>include\bitcoin\node\protocols</Filter>
</ClInclude>
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include <bitcoin/node/protocols/protocol_transaction_out_106.hpp>
#include <bitcoin/node/protocols/protocol_web.hpp>
#include <bitcoin/node/protocols/protocol_websocket.hpp>
#include <bitcoin/node/protocols/protocol_websocket_handshake.hpp>
#include <bitcoin/node/protocols/protocols.hpp>
#include <bitcoin/node/sessions/session.hpp>
#include <bitcoin/node/sessions/session_inbound.hpp>
Expand Down
14 changes: 8 additions & 6 deletions include/bitcoin/node/protocols/protocol_websocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,37 @@

#include <memory>
#include <bitcoin/node/define.hpp>
#include <bitcoin/node/protocols/protocol_http.hpp>
#include <bitcoin/node/protocols/protocol.hpp>

namespace libbitcoin {
namespace node {

// TODO: maybe make this an intermediate base class for websockets.
// TODO: make this an intermediate base class for websocket.
// TODO: and then create a distinct concrete class for deployment.
class BCN_API protocol_websocket
: public node::protocol_http,
: public network::protocol_websocket,
public node::protocol,
protected network::tracker<protocol_websocket>
{
public:
typedef std::shared_ptr<protocol_websocket> ptr;

// Replace base class channel_t (node::channel_http).
// Replace base class channel_t (network::channel_websocket).
using channel_t = node::channel_websocket;

protocol_websocket(const auto& session,
const network::channel::ptr& channel,
const options_t& options) NOEXCEPT
: node::protocol_http(session, channel, options),
: network::protocol_websocket(session, channel, options),
node::protocol(session, channel),
network::tracker<protocol_websocket>(session->log)
{
}

/// Public start is required.
void start() NOEXCEPT override
{
node::protocol_http::start();
network::protocol_websocket::start();
}

private:
Expand Down
65 changes: 65 additions & 0 deletions include/bitcoin/node/protocols/protocol_websocket_handshake.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_WEBSOCKET_HANDSHAKE_HPP
#define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_WEBSOCKET_HANDSHAKE_HPP

#include <memory>
#include <bitcoin/node/define.hpp>
#include <bitcoin/node/protocols/protocol.hpp>

namespace libbitcoin {
namespace node {

// TODO: make this an intermediate base class for websocket_handshake.
// TODO: and then create a distinct concrete class for deployment.
class BCN_API protocol_websocket_handshake
: public network::protocol_websocket_handshake,
public node::protocol,
protected network::tracker<protocol_websocket_handshake>
{
public:
typedef std::shared_ptr<protocol_websocket_handshake> ptr;

// Replace base class channel_t (network::channel_http).
using channel_t = node::channel_http;

protocol_websocket_handshake(const auto& session,
const network::channel::ptr& channel,
const options_t& options) NOEXCEPT
: network::protocol_websocket_handshake(session, channel, options),
node::protocol(session, channel),
network::tracker<protocol_websocket_handshake>(session->log)
{
}

/// Public start is required.
void start() NOEXCEPT override
{
network::protocol_websocket_handshake::start();
}

private:
// This is thread safe.
////const options_t& options_;
};

} // namespace node
} // namespace libbitcoin

#endif
2 changes: 2 additions & 0 deletions include/bitcoin/node/protocols/protocols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@
#include <bitcoin/node/protocols/protocol_electrum.hpp>
#include <bitcoin/node/protocols/protocol_stratum_v1.hpp>
#include <bitcoin/node/protocols/protocol_stratum_v2.hpp>
#include <bitcoin/node/protocols/protocol_websocket.hpp>
#include <bitcoin/node/protocols/protocol_websocket_handshake.hpp>

#endif
Loading