algotradelib
0.0.0.9000
C++ header-only library for algorithmic trading
Toggle main menu visibility
Loading...
Searching...
No Matches
ws_session.hpp
1
#pragma once
2
3
#include "./ws_session_base.hpp"
4
5
namespace
algotradelib::network
{
6
12
class
WsSession
:
public
WebSocketSessionBase<WsSession, websocket::stream<beast::tcp_stream>> {
13
public
:
22
WsSession
(
23
net::io_context& ioc, std::string host, std::string port, std::string target =
"/"
,
24
std::map<std::string, std::string> headers = {}
25
)
26
:
WebSocketSessionBase
(
27
ioc, std::move(host), std::move(port),
WebSocketSessionOptions
{std::move(target), std::move(headers)}
28
) {}
29
30
private
:
31
template
<
typename
,
typename
>
32
friend
class
WebSocketSessionBase;
33
friend
struct
WebSocketSessionTestAccess;
34
using
Stream = websocket::stream<beast::tcp_stream>;
35
36
void
do_connect() {
37
if
(
connected_
||
connecting_
||
closing_
||
stop_requested_
) {
38
return
;
39
}
40
ws_
= std::make_unique<Stream>(
strand_
);
41
buffer_
.consume(
buffer_
.size());
42
start_resolve
();
43
}
44
45
void
on_connect(beast::error_code error, tcp::resolver::results_type::endpoint_type endpoint) {
46
if
(error) {
47
fail
(
"connect"
, error);
48
return
;
49
}
50
if
(
abandon_if_closing
()) {
51
return
;
52
}
53
host_header_
=
host_
+
":"
+ std::to_string(endpoint.port());
54
start_ws_handshake
();
55
}
56
};
57
58
}
// namespace algotradelib::network
algotradelib::network::WebSocketSessionBase
The base of the WebSocket clients WsSession and WssSession: connecting, sending, receiving,...
Definition
ws_session_base.hpp:72
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::host_
std::string host_
Definition
ws_session_base.hpp:186
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::abandon_if_closing
bool abandon_if_closing()
Definition
ws_session_base.hpp:252
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::start_ws_handshake
void start_ws_handshake()
Definition
ws_session_base.hpp:228
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::fail
void fail(std::string_view stage, beast::error_code error)
Definition
ws_session_base.hpp:272
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::stop_requested_
bool stop_requested_
Definition
ws_session_base.hpp:202
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::host_header_
std::string host_header_
Definition
ws_session_base.hpp:190
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::connected_
bool connected_
Definition
ws_session_base.hpp:194
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::start_resolve
void start_resolve()
Definition
ws_session_base.hpp:217
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::connecting_
bool connecting_
Definition
ws_session_base.hpp:196
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::buffer_
beast::flat_buffer buffer_
Definition
ws_session_base.hpp:182
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::closing_
bool closing_
Definition
ws_session_base.hpp:198
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::ws_
std::unique_ptr< websocket::stream< beast::tcp_stream > > ws_
Definition
ws_session_base.hpp:180
algotradelib::network::WebSocketSessionBase< WsSession, websocket::stream< beast::tcp_stream > >::strand_
net::strand< net::io_context::executor_type > strand_
Definition
ws_session_base.hpp:174
algotradelib::network::WsSession::WsSession
WsSession(net::io_context &ioc, std::string host, std::string port, std::string target="/", std::map< std::string, std::string > headers={})
Constructs a session.
Definition
ws_session.hpp:22
algotradelib::network
HTTP and WebSocket transport, OAuth tokens, and request pacing.
Definition
calendar_cache.hpp:10
algotradelib::network::WebSocketSessionOptions
Options for a WebSocket session (WsSession, WssSession).
Definition
ws_session_base.hpp:40
algotradelib
src
network
ws_session.hpp
Generated by
1.18.0