20#ifndef ORES_COMMS_MESSAGING_HANDSHAKE_PROTOCOL_HPP
21#define ORES_COMMS_MESSAGING_HANDSHAKE_PROTOCOL_HPP
27#include "ores.comms/messaging/frame.hpp"
28#include "ores.comms/messaging/error_protocol.hpp"
39constexpr std::uint8_t COMPRESSION_SUPPORT_GZIP = 0x02;
40constexpr std::uint8_t COMPRESSION_SUPPORT_BZIP2 = 0x04;
41constexpr std::uint8_t COMPRESSION_SUPPORT_ALL = 0x07;
47 std::uint16_t client_version_major;
48 std::uint16_t client_version_minor;
49 std::string client_identifier;
70 static std::expected<handshake_request, error_code>
78 std::uint16_t server_version_major;
79 std::uint16_t server_version_minor;
80 bool version_compatible;
81 std::string server_identifier;
100 static std::expected<handshake_response, error_code>
118 static std::expected<handshake_ack, error_code>
131 std::uint32_t sequence,
132 const std::string& client_identifier,
133 std::uint8_t supported_compression = 0);
146 std::uint32_t sequence,
147 bool version_compatible,
148 const std::string& server_identifier,
149 error_code status = error_code::none,
156 std::uint32_t sequence,
157 error_code status = error_code::none);
168 std::uint32_t sequence,
169 std::uint32_t correlation_id,
171 const std::string& message);
184 std::uint8_t supported_compression,
Contains messaging related infrastructure in the comms library.
Definition compression.hpp:29
frame create_error_response_frame(std::uint32_t sequence, std::uint32_t correlation_id, error_code code, const std::string &message)
Create an error response frame.
Definition handshake.cpp:178
frame create_handshake_response_frame(std::uint32_t sequence, bool version_compatible, const std::string &server_identifier, error_code status=error_code::none, compression_type selected_compression=compression_type::none)
Create a handshake response frame.
Definition handshake.cpp:146
constexpr std::uint8_t COMPRESSION_SUPPORT_ZLIB
Compression support bitmask values.
Definition handshake_protocol.hpp:38
frame create_handshake_request_frame(std::uint32_t sequence, const std::string &client_identifier, std::uint8_t supported_compression=0)
Create a handshake request frame.
Definition handshake.cpp:123
frame create_handshake_ack_frame(std::uint32_t sequence, error_code status=error_code::none)
Create a handshake acknowledgment frame.
Definition handshake.cpp:169
compression_type
Compression algorithm used for payload compression.
Definition message_types.hpp:104
compression_type select_compression(std::uint8_t supported_compression, compression_type preferred=compression_type::zlib)
Select a compression type from the client's supported types.
Definition handshake.cpp:192
Complete frame with header and payload.
Definition frame.hpp:77
Handshake request message sent by client to initiate connection.
Definition handshake_protocol.hpp:46
static std::vector< std::byte > serialize(handshake_request v)
Serialize to frame payload.
Definition handshake.cpp:43
static std::expected< handshake_request, error_code > deserialize(std::span< const std::byte > data)
Deserialize from frame payload.
Definition handshake.cpp:52
std::uint8_t supported_compression
Bitmask of compression types supported by the client.
Definition handshake_protocol.hpp:60
Handshake response message sent by server to client.
Definition handshake_protocol.hpp:77
static std::vector< std::byte > serialize(handshake_response v)
Serialize to frame payload.
Definition handshake.cpp:63
compression_type selected_compression
Compression type selected for this session.
Definition handshake_protocol.hpp:90
static std::expected< handshake_response, error_code > deserialize(std::span< const std::byte > data)
Deserialize from frame payload.
Definition handshake.cpp:72
Handshake acknowledgment message sent by client to complete handshake.
Definition handshake_protocol.hpp:107
static std::expected< handshake_ack, error_code > deserialize(std::span< const std::byte > data)
Deserialize from frame payload.
Definition handshake.cpp:92
static std::vector< std::byte > serialize(handshake_ack v)
Serialize to frame payload.
Definition handshake.cpp:83