2#ifndef _KURLYK_WEBSOCKET_MANAGER_HPP_INCLUDED
3#define _KURLYK_WEBSOCKET_MANAGER_HPP_INCLUDED
10#ifdef KURLYK_USE_EMSCRIPTEN
14#ifdef KURLYK_USE_SIMPLEWEB
20#ifdef KURLYK_USE_EMSCRIPTEN
22 using selected_backend_client_t = EmscriptenWebSocketClientAdapter;
23#elif defined(KURLYK_USE_SIMPLEWEB)
25 using selected_backend_client_t = SimpleWebSocketClientAdapter;
52 if (
auto client_ptr = client_weak_ptr.lock()) {
53 client_ptr->process();
58 return client_weak_ptr.expired();
68 if (
auto client_ptr = client_weak_ptr.lock()) {
69 client_ptr->shutdown();
79 if (
auto client_ptr = client_weak_ptr.lock()) {
80 if (client_ptr->is_running())
return true;
91# ifdef KURLYK_USE_EMSCRIPTEN
93# if __cplusplus >= 201402L
94 client = std::make_shared<selected_backend_client_t>();
100# ifdef KURLYK_USE_SIMPLEWEB
102# if __cplusplus >= 201402L
103 client = std::make_shared<selected_backend_client_t>();
Contains the definition of the BaseWebSocketClient class, which provides the base functionality for W...
Declares the SimpleWebSocketClientAdapter implementation for WebSocket communication using Simple-Web...
WebSocketManager()=default
Private constructor to enforce singleton pattern.
static WebSocketManager & get_instance()
Get the singleton instance of WebSocketManager.
void shutdown() override
Shuts down all active backend-specific WebSocket clients managed by this instance.
std::mutex m_client_list_mutex
Mutex for synchronizing access to the client list.
selected_backend_client_ptr create_client()
Creates and returns a new backend-specific WebSocket client selected by compilation flags.
std::list< selected_backend_client_weak_ptr > m_client_list
List of managed backend-specific WebSocket clients.
virtual ~WebSocketManager()=default
Private destructor to enforce singleton pattern.
WebSocketManager(const WebSocketManager &)=delete
Deleted copy constructor to enforce the singleton pattern.
WebSocketManager & operator=(const WebSocketManager &)=delete
Deleted copy assignment operator to enforce the singleton pattern.
const bool is_loaded() const override
Checks if any managed backend-specific WebSocket client is currently running.
void process() override
Processes all active backend-specific WebSocket clients managed by this instance.
Interface for modules managed by NetworkWorker (e.g., HTTP, WebSocket).
Primary namespace for the Kurlyk library, encompassing initialization, request management,...
std::shared_ptr< selected_backend_client_t > selected_backend_client_ptr
Shared pointer to the compile-time selected backend client type.
std::weak_ptr< selected_backend_client_t > selected_backend_client_weak_ptr
Weak pointer to the compile-time selected backend client type.