32 #ifndef LEDGER_CORE_ABSTRACTLEDGERAPIBLOCKCHAINOBSERVER_H 33 #define LEDGER_CORE_ABSTRACTLEDGERAPIBLOCKCHAINOBSERVER_H 35 #include "AbstractBlockchainObserver.h" 36 #include <net/WebSocketClient.h> 37 #include <net/WebSocketConnection.h> 43 virtual std::shared_ptr<spdlog::logger>
logger()
const = 0;
44 virtual void connect() = 0;
45 virtual void reconnect() = 0;
47 virtual void onMessage(
const std::string& message) = 0;
50 void onSocketEvent(WebSocketEventType event,
51 const std::shared_ptr<WebSocketConnection> &connection,
55 case WebSocketEventType::CONNECT:
58 logger()->info(
"Connected to websocket {}", _url);
60 case WebSocketEventType::RECEIVE:
61 onMessage(message.getValue());
63 case WebSocketEventType::CLOSE:
67 logger()->error(
"An error occured to the connection with {}: {}", _url, message.getValue());
69 logger()->info(
"Close connection to {}", _url);
74 std::shared_ptr<WebSocketConnection> _socket;
81 #endif //LEDGER_CORE_ABSTRACTLEDGERAPIBLOCKCHAINOBSERVER_H Definition: AbstractLedgerApiBlockchainObserver.h:40
Definition: Account.cpp:8
Definition: logger.hpp:44