Kurlyk
Loading...
Searching...
No Matches
IWebSocketClient.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _KURLYK_IWEBSOCKET_CLIENT_HPP_INCLUDED
3#define _KURLYK_IWEBSOCKET_CLIENT_HPP_INCLUDED
4
7
8namespace kurlyk {
9
13 public:
14
16 IWebSocketClient() = default;
17
19 virtual ~IWebSocketClient() = default;
20
26 virtual std::function<void(std::unique_ptr<WebSocketEventData>)>& event_handler() = 0;
27
33 virtual std::function<void()>& notify_handler() = 0;
34
38 virtual void set_config(
39 std::unique_ptr<WebSocketConfig> config,
40 std::function<void(bool)> callback) = 0;
41
44 virtual void connect(std::function<void(bool)> callback) = 0;
45
48 virtual void disconnect(std::function<void(bool)> callback) = 0;
49
52 virtual bool is_running() const = 0;
53
58 virtual std::list<std::unique_ptr<WebSocketEventData>> receive_events() const = 0;
59
64 virtual std::unique_ptr<WebSocketEventData> receive_event() const = 0;
65
70 virtual void process() = 0;
71
74 virtual void shutdown() = 0;
75
76 }; // IWebSocketClient
77
79 using WebSocketClientPtr = std::shared_ptr<IWebSocketClient>;
80
81} // namespace kurlyk
82
83#endif // _KURLYK_IWEBSOCKET_CLIENT_HPP_INCLUDED
virtual void connect(std::function< void(bool)> callback)=0
Initiates a connection to the WebSocket server.
virtual void disconnect(std::function< void(bool)> callback)=0
Closes the connection to the WebSocket server.
virtual bool is_running() const =0
Checks if the WebSocket client is actively running.
IWebSocketClient()=default
Default constructor.
virtual std::unique_ptr< WebSocketEventData > receive_event() const =0
Retrieves the next available WebSocket event, if any.
virtual std::list< std::unique_ptr< WebSocketEventData > > receive_events() const =0
Retrieves all pending WebSocket events in a batch.
virtual void set_config(std::unique_ptr< WebSocketConfig > config, std::function< void(bool)> callback)=0
Sets the configuration for the WebSocket client.
virtual std::function< void()> & notify_handler()=0
Accesses the notification handler for WebSocket events.
virtual ~IWebSocketClient()=default
Virtual destructor for safe cleanup in derived classes.
virtual void process()=0
Processes internal operations such as event handling and state updates.
virtual std::function< void(std::unique_ptr< WebSocketEventData >)> & event_handler()=0
Accessor for the event handler function.
virtual void shutdown()=0
Shuts down the WebSocket client, disconnecting and clearing all pending events.
IWebSocketSender()=default
Default constructor for IWebSocketSender.
Primary namespace for the Kurlyk library, encompassing initialization, request management,...
std::shared_ptr< IWebSocketClient > WebSocketClientPtr
Alias for a shared pointer to an IWebSocketClient instance.