Abstract application server. More...
#include <StormByte/network/server.hxx>


Public Member Functions | |
| Server (DeserializePacketFunction deserialize_packet_function, StormByte::Safe::Shared< Logger::Log > logger) | |
| Construct with a packet factory and a logger. | |
| Server (const Server &other)=delete | |
| Copy constructor (deleted). | |
| Server (Server &&other) noexcept | |
| Stop the source before transferring its inactive state. | |
| virtual | ~Server () noexcept |
| Destructor (joins threads, disconnects clients). | |
| Server & | operator= (const Server &other)=delete |
| Copy assignment (deleted). | |
| Server & | operator= (Server &&other) noexcept |
| Stop both servers before transferring inactive state. | |
| bool | Connect (const Connection::Protocol &protocol, std::string_view address, const unsigned short &port) override |
| Bind, listen and start the accept thread. | |
| bool | ConfigureTLS (const Crypto::TLS::ServerConfiguration &configuration, bool refresh_validation_time=true) noexcept |
| Require TLS for new application and remote-file connections. | |
| bool | DisableTLS () noexcept |
| Restore plaintext while the server is stopped. | |
| void | Disconnect () noexcept override |
| Stop accept, disconnect clients and close the listener. | |
| Connection::Status | Status () const noexcept override |
| Listener / server status. | |
| StormByte::Safe::Shared< ServerTelemetry > | Telemetry () const noexcept |
| Shared live telemetry aggregated across this Server's sessions. | |
| bool | Announce (const Connection::Protocol &protocol, unsigned short discovery_port) noexcept |
Start listening for discovery queries on discovery_port. | |
| void | StopAnnounce () noexcept |
| Stop the discovery listener. | |
Protected Member Functions | |
| virtual bool | AllowIncomingOpcode (std::string_view uuid, Transport::Packet::OpcodeType opcode) const noexcept |
| Admit an application opcode before its pipeline and factory run. | |
| virtual bool | AllowOutgoingOpcode (std::string_view uuid, Transport::Packet::OpcodeType opcode) const noexcept |
| Admit a response opcode before output transformation. | |
| RemoteFileMount | MountRemoteFileReader (std::string_view client_uuid, std::string_view path, std::uint16_t maximum_timeout_seconds=30) noexcept |
| Mount a server-owned file for an already authorized client session. | |
| RemoteFileMount | MountRemoteFileWriter (std::string_view client_uuid, std::string_view path, std::uint16_t maximum_timeout_seconds=30) noexcept |
| Mount a server-owned file for exclusive writing after application authorization. | |
| void | DisconnectClient (std::string_view uuid) noexcept |
| Disconnect a client by UUID. | |
| Safe::Optional< PeerAddress > | GetPeerAddress (std::string_view uuid) |
| Get the remote address for an active client session. | |
| void | DisconnectClientAfterReply (std::string_view uuid) noexcept |
| Send the current handler's reply, then close and discard pending input. | |
| virtual bool | OnClientConnected (std::string_view uuid) noexcept |
| Admit and initialize a newly registered application session. | |
| virtual void | OnClientDisconnected (std::string_view uuid) noexcept |
| Release derived state when an application session is removed. | |
| virtual StormByte::Safe::Binary | OnDiscoveryQuery (const StormByte::Safe::Binary &query) const noexcept |
| Decide whether to answer a discovery query. | |
Abstract application server.
Forward declaration of the server owning its telemetry.
Listen socket and single-threaded event loop. Implement ProcessClientPacket(); optionally require TLS before starting the listener.
| StormByte::Network::Server::Server | ( | DeserializePacketFunction | deserialize_packet_function, |
| StormByte::Safe::Shared< Logger::Log > | logger ) |
Construct with a packet factory and a logger.
| deserialize_packet_function | Builds domain packets from wire data. |
| logger | Diagnostic logger. |
|
delete |
Copy constructor (deleted).
| other | Server that cannot be copied. |
|
noexcept |
Stop the source before transferring its inactive state.
| other | Server whose state is transferred. |
|
virtualnoexcept |
Destructor (joins threads, disconnects clients).
|
protectedvirtualnoexcept |
Admit an application opcode before its pipeline and factory run.
| uuid | Server-assigned session identity. |
| opcode | Incoming application opcode. |
Runs on the event loop; synchronize state shared with workers. Frames coalesced with a handshake remain raw until the preceding handler completes. This hook then sees its updated session policy before any input transformation or packet factory executes for the next message.
|
protectedvirtualnoexcept |
Admit a response opcode before output transformation.
| uuid | Server-assigned session identity. |
| opcode | Outgoing application opcode. |
Runs on the event loop; synchronize state shared with workers.
|
noexcept |
Start listening for discovery queries on discovery_port.
| protocol | Address family (IPv4 broadcast or IPv6 multicast). |
| discovery_port | UDP port to bind. |
Independent of the TCP Connect. Stop with StopAnnounce.
|
noexcept |
Require TLS for new application and remote-file connections.
| configuration | Borrowed identity, mTLS roots and policy copied synchronously. |
| refresh_validation_time | Use current time for each new session by default; false explicitly preserves the supplied client-certificate validation instant. |
Each accepted channel owns an independent incremental TLS session. OnClientConnected runs only after successful TLS authentication. Externally serialize configuration, connection, moves and destruction.
|
overridevirtual |
Bind, listen and start the accept thread.
| protocol | Address family. |
| address | Bind address. |
| port | Port number. |
Implements StormByte::Network::Endpoint.
|
noexcept |
Restore plaintext while the server is stopped.
|
overridevirtualnoexcept |
Stop accept, disconnect clients and close the listener.
Implements StormByte::Network::Endpoint.
|
protectednoexcept |
Disconnect a client by UUID.
| uuid | Client UUID. |
|
protectednoexcept |
Send the current handler's reply, then close and discard pending input.
| uuid | Session handled by the calling packet worker. |
Call before returning the rejection packet from ProcessClientPacket. Network does not interpret its opcode. No subsequent queued frame is transformed, deserialized or dispatched; closure follows output draining.
|
protected |
Get the remote address for an active client session.
| uuid | Server-assigned session identity. |
Safe to call from server callbacks and packet workers.
|
protectednoexcept |
Mount a server-owned file for an already authorized client session.
| client_uuid | Client session which owns this capability. |
| path | Server-local path selected by application policy. |
| maximum_timeout_seconds | Heartbeat timeout in [3, 3600] seconds. |
|
protectednoexcept |
Mount a server-owned file for exclusive writing after application authorization.
| client_uuid | Requesting application session. |
| path | Server-local file path selected by application policy. |
| maximum_timeout_seconds | Heartbeat timeout in [3, 3600] seconds. |
|
protectedvirtualnoexcept |
Admit and initialize a newly registered application session.
| uuid | Server-assigned session identity, borrowed for this call. |
Called on the event-loop thread before any packet is dispatched. The default accepts the session. Do not block waiting for network I/O or workers; perform an application login in ProcessClientPacket instead. Synchronize derived state shared with packet workers. Rejected sessions also receive OnClientDisconnected.
|
protectedvirtualnoexcept |
Release derived state when an application session is removed.
| uuid | Removed session identity, borrowed for this call. |
Called once on the event-loop thread, including server shutdown. The default does nothing. An already dispatched worker may still finish; derived handlers must not recreate authorization for a removed session. Do not wait for workers in this callback. Derived destructors must call Disconnect before destroying state used by these hooks or handlers.
|
protectedvirtualnoexcept |
Decide whether to answer a discovery query.
| query | Opaque query payload. |
Copy assignment (deleted).
| other | Server that cannot be copied. |
Stop both servers before transferring inactive state.
| other | Server whose state is transferred. |
|
overridevirtualnoexcept |
|
noexcept |
Stop the discovery listener.
|
noexcept |
Shared live telemetry aggregated across this Server's sessions.