Skip to content

Commit

Permalink
Comments/updates based on feedback
Browse files Browse the repository at this point in the history
Signed-off-by: AssemblyJohn <[email protected]>
  • Loading branch information
AssemblyJohn committed Dec 5, 2024
1 parent e450b0e commit d258bb6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
15 changes: 1 addition & 14 deletions include/ocpp/common/websocket/websocket_libwebsockets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
#include <ocpp/common/safe_queue.hpp>
#include <ocpp/common/websocket/websocket_base.hpp>

#include <condition_variable>
#include <memory>
#include <mutex>
#include <optional>
#include <queue>
#include <string>

struct ssl_ctx_st;
Expand All @@ -32,29 +29,19 @@ class WebsocketLibwebsockets final : public WebsocketBase {

void set_connection_options(const WebsocketConnectionOptions& connection_options) override;

/// \brief 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
bool start_connecting() override;

/// \brief Reconnects the websocket after the delay. Will stop the current connection attempts
/// and will call the 'start_connecting' after the delay
/// \param reason parameter
/// \param delay delay of the reconnect attempt
void reconnect(long delay) override;

/// \brief closes the websocket
void close(const WebsocketCloseReason code, const std::string& reason) override;

/// \brief send a \p message over the websocket
/// \returns true if the message was sent successfully
bool send(const std::string& message) override;

/// \brief send a websocket ping
void ping() override;

/// \brief Indicates if the websocket has a valid connection data and is trying to
/// connect/reconnect internally even if for the moment it might not be connected
/// \return True if the websocket is connected or trying to connect, false otherwise
bool is_trying_to_connect();

public:
Expand Down
3 changes: 2 additions & 1 deletion lib/ocpp/common/websocket/websocket_libwebsockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#include <libwebsockets.h>

#include <atomic>
#include <condition_variable>
#include <fstream>
#include <memory>
#include <mutex>
#include <stdexcept>
#include <string>

Expand Down Expand Up @@ -797,7 +799,6 @@ void WebsocketLibwebsockets::thread_websocket_client_loop(std::shared_ptr<Connec
if (local_data->is_interupted() || local_data->get_state() == EConnectionState::FINALIZED) {
EVLOG_info << "Connection interrupted or cleanly finalized, exiting websocket loop";
try_reconnect = false;
// TODO:
} else if (local_data->get_state() != EConnectionState::CONNECTED) {
// Any other failure than a successful connect

Expand Down

0 comments on commit d258bb6

Please sign in to comment.