3#ifndef OCPP_WEBSOCKET_HPP
4#define OCPP_WEBSOCKET_HPP
6#include <ocpp/common/evse_security.hpp>
7#include <ocpp/common/ocpp_logging.hpp>
9#include <ocpp/common/websocket/websocket_base.hpp>
18 std::unique_ptr<WebsocketBase> websocket;
19 std::function<void(OcppProtocolVersion protocol)> connected_callback;
20 std::function<void()> disconnected_callback;
21 std::function<void(
const WebsocketCloseReason reason)> stopped_connecting_callback;
22 std::function<void(
const std::string& message)> message_callback;
23 std::shared_ptr<MessageLogging> logging;
28 std::shared_ptr<EvseSecurity> evse_security, std::shared_ptr<MessageLogging> logging);
39 void disconnect(
const WebsocketCloseReason code);
42 void reconnect(
long delay);
65 bool send(
const std::string& message);
contains a websocket abstraction that can connect to TLS and non-TLS websocket endpoints
Definition: websocket.hpp:15
void set_websocket_ping_interval(int32_t interval_s)
set the websocket ping interval interval_s in seconds
Definition: websocket.cpp:88
void register_stopped_connecting_callback(const std::function< void(const WebsocketCloseReason)> &callback)
register a callback that is called when the websocket connection has been stopped and will not attemp...
Definition: websocket.cpp:66
bool is_connected()
indicates if the websocket is connected
Definition: websocket.cpp:44
Websocket(const WebsocketConnectionOptions &connection_options, std::shared_ptr< EvseSecurity > evse_security, std::shared_ptr< MessageLogging > logging)
Creates a new Websocket object with the provided connection_options.
Definition: websocket.cpp:16
void register_disconnected_callback(const std::function< void()> &callback)
register a callback that is called when the websocket connection is disconnected
Definition: websocket.cpp:57
bool start_connecting()
Starts the connection attempts. It will init the websocket processing thread.
Definition: websocket.cpp:25
bool send(const std::string &message)
send a message over the websocket
Definition: websocket.cpp:83
void register_connected_callback(const std::function< void(OcppProtocolVersion protocol)> &callback)
register a callback that is called when the websocket is connected successfully
Definition: websocket.cpp:48
void register_connection_failed_callback(const std::function< void(ConnectionFailedReason)> &callback)
register a callback that is called when the websocket could not connect with a specific reason
Definition: websocket.cpp:79
void set_authorization_key(const std::string &authorization_key)
set the authorization_key of the connection_options
Definition: websocket.cpp:93
void register_message_callback(const std::function< void(const std::string &message)> &callback)
register a callback that is called when the websocket receives a message
Definition: websocket.cpp:73
void disconnect(const WebsocketCloseReason code)
disconnect the websocket
Definition: websocket.cpp:34
Definition: websocket_base.hpp:18