19#ifndef CPPREALM_NETWORKING_WEBSOCKET_HPP
20#define CPPREALM_NETWORKING_WEBSOCKET_HPP
22#include <cpprealm/internal/bridge/status.hpp>
23#include <cpprealm/internal/bridge/realm.hpp>
25#ifndef REALMCXX_VERSION_MAJOR
26#include <cpprealm/version_numbers.hpp>
34 class SyncSocketProvider;
35 struct WebSocketInterface;
36 struct WebSocketObserver;
44namespace realm::networking {
53 enum class websocket_err_codes {
56 protocol_error = 1002,
57 unsupported_data = 1003,
58 websocket_reserved = 1004,
59 no_status_received = 1005,
60 abnormal_closure = 1006,
61 invalid_payload_data = 1007,
62 policy_violation = 1008,
63 message_too_big = 1009,
64 invalid_extension = 1010,
65 invalid_server_error = 1011,
66 TLS_handshake_failed = 1015,
70 moved_permanently = 4003,
71 client_too_old = 4004,
72 client_too_new = 4005,
73 protocol_mismatch = 4006,
75 resolve_failed = 4400,
76 connection_failed = 4401,
84 struct websocket_interface;
85 struct websocket_observer;
137 using sync_timer = std::unique_ptr<sync_socket_provider::timer>;
149 virtual std::unique_ptr<websocket_interface>
connect(std::unique_ptr<websocket_observer> observer,
203 using FunctionHandler = std::function<void(
status)>;
263 std::string_view message) = 0;
276 std::optional<::realm::internal::bridge::realm::sync_config::proxy_config>
proxy_config;
278 using SSLVerifyCallback = bool(
const std::string& server_address,
279 internal::bridge::realm::sync_config::proxy_config::port_type server_port,
280 const char* pem_data,
size_t pem_size,
int preverify_ok,
int depth);
308 std::unique_ptr<::realm::sync::SyncSocketProvider> m_provider;
Definition: websocket.hpp:112
virtual std::unique_ptr< websocket_interface > connect(std::unique_ptr< websocket_observer > observer, websocket_endpoint &&endpoint)=0
virtual ~sync_socket_provider()=default
std::unique_ptr< sync_socket_provider::timer > sync_timer
Other class typedefs.
Definition: websocket.hpp:137
std::function< void(status)> FunctionHandler
Function handler typedef.
Definition: websocket.hpp:116
virtual sync_timer create_timer(std::chrono::milliseconds delay, FunctionHandler &&handler)=0
virtual void post(FunctionHandler &&handler)=0
Definition: status.hpp:63
Definition: websocket.hpp:268
bool client_validate_ssl
Definition: websocket.hpp:284
std::optional<::realm::internal::bridge::realm::sync_config::proxy_config > proxy_config
Definition: websocket.hpp:276
std::function< SSLVerifyCallback > ssl_verify_callback
Definition: websocket.hpp:294
std::optional< std::map< std::string, std::string > > custom_http_headers
Definition: websocket.hpp:272
std::optional< std::string > ssl_trust_certificate_path
Definition: websocket.hpp:288
Built in websocket provider.
Definition: websocket.hpp:267
sync_timer create_timer(std::chrono::milliseconds delay, FunctionHandler &&) override
Definition: websocket.cpp:84
void post(FunctionHandler &&) override
Definition: websocket.cpp:78
std::unique_ptr< websocket_interface > connect(std::unique_ptr< websocket_observer >, websocket_endpoint &&) override
Definition: websocket.cpp:71
Definition: websocket.hpp:128
virtual ~timer()=default
Cancels the timer and destroys the timer instance.
Definition: websocket.hpp:46
std::vector< std::string > protocols
Array of one or more websocket protocols.
Definition: websocket.hpp:48
std::string url
The websocket url to connect to.
Definition: websocket.hpp:50
Definition: websocket.hpp:198
virtual ~websocket_interface()=default
virtual void async_write_binary(std::string_view data, FunctionHandler &&handler)=0
Definition: websocket.hpp:220
virtual void websocket_error_handler()=0
virtual void websocket_connected_handler(const std::string &protocol)=0
virtual bool websocket_binary_message_received(std::string_view data)=0
virtual bool websocket_closed_handler(bool was_clean, websocket_err_codes error_code, std::string_view message)=0