|
MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
|
TCP server for interactive live coding sessions in MayaFlux. More...
#include <Server.hpp>
Collaboration diagram for Lila::Server:Public Types | |
| using | ConnectionHandler = std::function< void(const ClientInfo &)> |
| Handler for client connection/disconnection events. | |
| using | MessageHandler = std::function< std::expected< std::string, std::string >(std::string_view)> |
| Handler for processing incoming client messages. | |
| using | StartHandler = std::function< void()> |
| Handler for server start events. | |
Public Member Functions | |
| void | broadcast_event (const StreamEvent &event, std::optional< std::string_view > target_session=std::nullopt) |
| void | broadcast_to_all (std::string_view message) |
| EventBus & | event_bus () |
| const EventBus & | event_bus () const noexcept |
| std::optional< std::string > | get_client_session (int client_id) const |
| std::vector< ClientInfo > | get_connected_clients () const |
| bool | is_running () const |
| void | on_client_connected (ConnectionHandler handler) |
| void | on_client_disconnected (ConnectionHandler handler) |
| void | on_server_started (StartHandler handler) |
| Server & | operator= (const Server &)=delete |
| Server (const Server &)=delete | |
| Server (int port=9090) | |
| void | set_client_session (int client_id, std::string session_id) |
| void | set_message_handler (MessageHandler handler) |
| bool | start () noexcept |
| void | stop () noexcept |
| ~Server () | |
Private Member Functions | |
| void | process_control_message (int client_id, std::string_view message) |
| void | register_session (const std::shared_ptr< ClientSession > &session) |
| void | remove_session (int client_id) |
| void | start_accept () |
Private Attributes | |
| std::unique_ptr< asio::ip::tcp::acceptor > | m_acceptor |
| std::shared_mutex | m_clients_mutex |
| ConnectionHandler | m_connect_handler |
| ConnectionHandler | m_disconnect_handler |
| EventBus | m_event_bus |
| asio::io_context | m_io_context |
| std::thread | m_io_thread |
| MessageHandler | m_message_handler |
| int | m_next_client_id { 1 } |
| int | m_port |
| std::atomic< bool > | m_running { false } |
| std::unordered_map< int, std::shared_ptr< ClientSession > > | m_sessions |
| StartHandler | m_start_handler |
Friends | |
| class | ClientSession |
TCP server for interactive live coding sessions in MayaFlux.
Async TCP server built on asio. Accepts newline-delimited messages, dispatches them to a message handler, and returns the response. Control messages prefixed with '@' are handled internally.
Definition at line 20 of file Server.hpp.