29#include <unordered_map>
48 std::unordered_map<irsol::types::client_id_t, std::shared_ptr<ClientSession>>;
90 const std::optional<irsol::types::client_id_t>& excludeClient = std::nullopt);
181 template<
typename InMessageT,
typename HandlerT,
typename... Args>
187 if(!
messageHandler.template registerHandler<InMessageT>(identifier, handler)) {
188 IRSOL_LOG_FATAL(
"Failed to register handler for identifier {}", identifier);
189 throw std::runtime_error(
"Failed to register handler for identifier '" + identifier +
"'");
212 template<
typename InMessageT,
typename LambdaT>
214 const std::string& identifier,
215 std::shared_ptr<handlers::Context> ctx,
221 if(!
messageHandler.template registerHandler<InMessageT>(identifier, handler)) {
222 IRSOL_LOG_FATAL(
"Failed to register lambda handler for identifier {}", identifier);
223 throw std::runtime_error(
224 "Failed to register lambda handler for identifier '" + identifier +
"'");
Accepts and forwards incoming client connections to the session handler.
High-level wrapper around the NeoAPI camera for synchronized access.
Main server application that manages client connections and camera streaming.
const irsol::types::port_t m_port
TCP port on which the server listens.
std::unordered_map< irsol::types::client_id_t, std::shared_ptr< ClientSession > > client_map_t
irsol::server::internal::ClientSessionAcceptor m_acceptor
Acceptor that handles incoming client connections.
camera::Interface & camera()
Accessor for the camera interface.
const handlers::MessageHandler & messageHandler() const
Accessor for the message handler.
std::thread m_acceptThread
Thread running the connection acceptor loop.
void addClient(const irsol::types::client_id_t &clientId, irsol::types::socket_t &&sock)
Adds a new client session.
std::unique_ptr< frame_collector::FrameCollector > m_frameCollector
Frame collector for capturing and broadcasting camera frames.
frame_collector::FrameCollector & frameCollector()
Accessor for the frame collector.
std::shared_ptr< ClientSession > getClientSession(const irsol::types::client_id_t &clientId)
Retrieves an active client session.
void registerMessageHandler(const std::string &identifier, Args &&... args)
Registers a message handler by type.
void broadcastMessage(protocol::OutMessage &&message, const std::optional< irsol::types::client_id_t > &excludeClient=std::nullopt)
Broadcasts a message to all connected clients.
void stop()
Stops the server.
bool start()
Starts the server.
void registerMessageHandlers()
Registers standard message handlers.
client_map_t m_clients
Map of connected clients.
std::unique_ptr< camera::Interface > m_cameraInterface
Interface to the camera.
void removeClient(const irsol::types::client_id_t &clientId)
Removes a client session.
void registerLambdaHandler(const std::string &identifier, std::shared_ptr< handlers::Context > ctx, LambdaT &&lambda)
Registers a lambda-based message handler.
std::mutex m_clientsMutex
Mutex for protecting access to m_clients.
std::unique_ptr< handlers::MessageHandler > m_messageHandler
Central handler for processing protocol messages.
Coordinates frame acquisition from a camera and distributes frames to registered clients.
Binds incoming protocol messages to the appropriate per-client logic.
Accepts incoming TCP connections and triggers a callback for each new client.
Factory utilities for constructing handler instances.
#define IRSOL_LOG_FATAL(...)
Logs a fatal (critical) message using the default logger.
std::variant< Success, BinaryDataBuffer, ImageBinaryData, ColorImageBinaryData, Error > OutMessage
Variant type representing any outgoing message.
High-level wrapper around NeoAPI camera control for the irsol library.
Message routing layer between protocol and application logic.
constexpr auto makeHandler(std::shared_ptr< Context > ctx, Args &&... args)
Constructs a handler instance of the given type.
std::string client_id_t
Represents a unique client identifier. Typically used to identify connected clients by string IDs.
uint16_t port_t
Represents a network port number. Typically used to specify TCP or UDP ports.
sockpp::tcp_socket socket_t
Alias for a TCP socket.
Core type definitions for networking, time handling, and protocol values used throughout the irsol li...