ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
Public Member Functions | List of all members
ocpp::MessageQueue< M > Class Template Reference

contains a message queue that makes sure that OCPPs synchronicity requirements are met More...

#include <message_queue.hpp>

Public Member Functions

 MessageQueue (const std::function< bool(json message)> &send_callback, const MessageQueueConfig< M > &config, const std::vector< M > &external_notify, std::shared_ptr< common::DatabaseHandlerCommon > database_handler, const std::function< void(const std::string &new_message_id, const std::string &old_message_id)> start_transaction_message_retry_callback=[](const std::string &new_message_id, const std::string &old_message_id) {})
 Creates a new MessageQueue object with the provided configuration and send_callback.
 
 MessageQueue (const std::function< bool(json message)> &send_callback, const MessageQueueConfig< M > &config, std::shared_ptr< common::DatabaseHandlerCommon > databaseHandler)
 
void start ()
 
void reset_next_message_to_send ()
 Resets next message to send. Can be used in situation when we dont want to reply to a CALL message.
 
void get_persisted_messages_from_db (bool ignore_security_event_notifications=false)
 Gets all persisted messages of normal message queue and persisted message queue from the database.
 
void push_call (const json &message, const bool stall_until_accepted=false)
 
void push_call_result (const json &call_result)
 Sends a new call_result message over the websocket.
 
void push_call_error (CallError call_error)
 Sends a new call_error message over the websocket.
 
std::future< EnhancedMessage< M > > push_call_async (const json &call)
 pushes a new call message onto the message queue More...
 
EnhancedMessage< M > receive (std::string_view message)
 Enhances a received json_message with additional meta information, checks if it is a valid CallResult with a corresponding Call message on top of the queue. More...
 
void reset_in_flight ()
 
void handle_call_result (EnhancedMessage< M > &enhanced_message)
 
void handle_timeout_or_callerror (const std::optional< EnhancedMessage< M > > &enhanced_message_opt)
 Handles a message timeout or a CALLERROR. enhanced_message_opt is set only in case of CALLERROR.
 
void stop ()
 Stops the message queue.
 
void pause ()
 Pauses the message queue.
 
void resume (std::chrono::seconds delay_on_reconnect)
 Resumes the message queue.
 
void set_registration_status_accepted ()
 
bool is_transaction_message_queue_empty ()
 
bool contains_transaction_messages (const CiString< 36 > transaction_id)
 
bool contains_stop_transaction_message (const int32_t transaction_id)
 
void update_transaction_message_attempts (const int transaction_message_attempts)
 Set transaction_message_attempts to given transaction_message_attempts.
 
void update_transaction_message_retry_interval (const int transaction_message_retry_interval)
 Set transaction_message_retry_interval to given transaction_message_retry_interval in seconds.
 
void update_message_timeout (const int timeout)
 Set message_timeout to given timeout (in seconds)
 
void add_stopped_transaction_id (std::string stop_transaction_message_id, int32_t transaction_id)
 Adds the given transaction_id to the message_id_transaction_id_map using the key stop_transaction_message_id.
 
void add_meter_value_message_id (const std::string &start_transaction_message_id, const std::string &meter_value_message_id)
 
void notify_start_transaction_handled (const std::string &start_transaction_message_id, const int32_t transaction_id)
 
string_to_messagetype (const std::string &s)
 
std::string messagetype_to_string (M m)
 
v16::MessageType string_to_messagetype (const std::string &s)
 
std::string messagetype_to_string (v16::MessageType m)
 
v2::MessageType string_to_messagetype (const std::string &s)
 
std::string messagetype_to_string (const v2::MessageType m)
 

Detailed Description

template<typename M>
class ocpp::MessageQueue< M >

contains a message queue that makes sure that OCPPs synchronicity requirements are met

Member Function Documentation

◆ push_call_async()

template<typename M >
std::future< EnhancedMessage< M > > ocpp::MessageQueue< M >::push_call_async ( const json &  call)
inline

pushes a new call message onto the message queue

Returns
a future from which the CallResult can be extracted

◆ receive()

template<typename M >
EnhancedMessage< M > ocpp::MessageQueue< M >::receive ( std::string_view  message)
inline

Enhances a received json_message with additional meta information, checks if it is a valid CallResult with a corresponding Call message on top of the queue.

Returns
the enhanced message

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