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
14 public:
15
17 IWebSocketClient() = default;
18
20 virtual ~IWebSocketClient() = default;
21
27 virtual std::function<void(std::unique_ptr<WebSocketEventData>)>& event_handler() = 0;
28
34 virtual std::function<void()>& notify_handler() = 0;
35
39 virtual void set_config(
40 std::unique_ptr<WebSocketConfig> config,
41 std::function<void(bool)> callback) = 0;
42
45 virtual void connect(std::function<void(bool)> callback) = 0;
46
49 virtual void disconnect(std::function<void(bool)> callback) = 0;
50
53 virtual bool is_running() const = 0;
54
59 virtual std::list<std::unique_ptr<WebSocketEventData>> receive_events() const = 0;
60
65 virtual std::unique_ptr<WebSocketEventData> receive_event() const = 0;
66
71 virtual void process() = 0;
72
75 virtual void shutdown() = 0;
76
77 }; // IWebSocketClient
78
80 using WebSocketClientPtr = std::shared_ptr<IWebSocketClient>;
81
82} // namespace kurlyk
83
84#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
Legacy shared-pointer alias for the internal compatibility interface.