|
ASIO Client Server Framework
|
Everything in the framework lives in this namespace. More...
Classes | |
| class | Client |
| A TCP client that connects to an acsf::Server and exchanges length-prefixed messages. More... | |
| struct | Log |
| One log entry. Every field is optional and only the fields that are set appear in the output. More... | |
| class | Logger |
| Writes log entries to rotating files in the background. Used internally by Server and Client. More... | |
| struct | LoggerConfig |
| Logging settings passed to acsf::Server and acsf::Client. More... | |
| struct | Message |
| A message received from the other side. More... | |
| class | Server |
| A TCP server that accepts many clients and exchanges length-prefixed messages with them. More... | |
Enumerations | |
| enum class | LogLevel { DEBUG , INFO , WARN , ERROR } |
| Severity of a log entry. More... | |
| enum class | TimeoutType { Read , ReadBody , Send , HeartbeatTimeout , HeartbeatRate } |
| Selects a timeout for Server::setTimeout(). More... | |
Functions | |
| std::string | levelToString (LogLevel level) |
| Converts a LogLevel to its upper case name, e.g. "WARN". | |
| void | setMaxLogFileSize (std::uintmax_t newSize) |
| Sets the size at which log files are rotated. | |
| void | setTimeout (std::chrono::milliseconds &targetTimeout, std::chrono::milliseconds timeout) |
| Changes one of the global timeouts. | |
| std::uint32_t | networkToHostLong (uint32_t bytes) |
| Converts a 32 bit value from network (big endian) to host byte order. | |
| std::uint32_t | hostToNetworkLong (uint32_t bytes) |
| Converts a 32 bit value from host to network (big endian) byte order. | |
| std::optional< std::vector< char > > | getMessageFrame (std::string_view body, bool isHeartBeat) |
| Builds the bytes put on the wire: a 4 byte big endian header followed by the body. The top bit of the header marks a heartbeat; the other 31 bits hold the body length. | |
| std::optional< std::pair< std::uint32_t, bool > > | parseHeader (const std::array< char, HeaderSize > &header) |
| Reads a 4 byte header. | |
Variables | |
| constexpr std::size_t | HeaderSize = 4 |
| Size in bytes of the length header in front of every message. | |
| constexpr std::uint32_t | MaxMessageSize = 1024 * 1024 |
| Largest allowed message body in bytes (1 MB). | |
| std::uintmax_t | MAX_LOG_FILE_SIZE = 10 * 1024 * 1024 |
| Default size in bytes at which a log file is rotated. Change with setMaxLogFileSize(). | |
| std::chrono::milliseconds | READ_TIMEOUT_MS {15000} |
| Global timeouts in milliseconds, shared by every server and client. Change them with setTimeout(). | |
Everything in the framework lives in this namespace.
|
strong |
|
strong |
Selects a timeout for Server::setTimeout().
|
inline |
Builds the bytes put on the wire: a 4 byte big endian header followed by the body. The top bit of the header marks a heartbeat; the other 31 bits hold the body length.
| body | Message body. |
| isHeartBeat | True for a heartbeat (the body may then be empty). |
|
inline |
Reads a 4 byte header.
| header | The header bytes. |
|
inline |
Sets the size at which log files are rotated.
| newSize | Size in bytes. Applies to loggers created afterwards. |
|
inline |
Changes one of the global timeouts.
| targetTimeout | The timeout to change: READ_TIMEOUT_MS, READ_BODY_TIMEOUT_MS, SEND_TIMEOUT_MS, SERVER_HEARTBEAT_TIMEOUT_MS or HEARTBEAT_RATE. |
| timeout | New value in milliseconds. 0 turns that timeout off. |
|
inline |
Global timeouts in milliseconds, shared by every server and client. Change them with setTimeout().