ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
Public Member Functions | List of all members
ocpp::Websocket Class Reference

contains a websocket abstraction that can connect to TLS and non-TLS websocket endpoints More...

#include <websocket.hpp>

Public Member Functions

 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.
 
bool start_connecting ()
 Starts the connection attempts. It will init the websocket processing thread. More...
 
void set_connection_options (const WebsocketConnectionOptions &connection_options)
 
void disconnect (const WebsocketCloseReason code)
 disconnect the websocket
 
void reconnect (long delay)
 
bool is_connected ()
 indicates if the websocket is connected
 
void register_connected_callback (const std::function< void(OcppProtocolVersion protocol)> &callback)
 register a callback that is called when the websocket is connected successfully
 
void register_disconnected_callback (const std::function< void()> &callback)
 register a callback that is called when the websocket connection is disconnected
 
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 attempt to reconnect
 
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
 
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
 
bool send (const std::string &message)
 send a message over the websocket More...
 
void set_websocket_ping_interval (int32_t interval_s)
 set the websocket ping interval interval_s in seconds
 
void set_authorization_key (const std::string &authorization_key)
 set the authorization_key of the connection_options
 

Detailed Description

contains a websocket abstraction that can connect to TLS and non-TLS websocket endpoints

Member Function Documentation

◆ send()

bool ocpp::Websocket::send ( const std::string &  message)

send a message over the websocket

Returns
true if the message was sent successfully

◆ start_connecting()

bool ocpp::Websocket::start_connecting ( )

Starts the connection attempts. It will init the websocket processing thread.

Returns
true if the websocket is successfully initialized, false otherwise. Does not wait for a successful connection

The documentation for this class was generated from the following files: