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"
29#include "ores.comms/messaging/message_traits.hpp"
40constexpr std::uint8_t COMPRESSION_SUPPORT_GZIP = 0x02;
41constexpr std::uint8_t COMPRESSION_SUPPORT_BZIP2 = 0x04;
42constexpr std::uint8_t COMPRESSION_SUPPORT_ALL = 0x07;
48 std::uint16_t client_version_major;
49 std::uint16_t client_version_minor;
50 std::string client_identifier;
71 static std::expected<handshake_request, ores::utility::serialization::error_code>
79 std::uint16_t server_version_major;
80 std::uint16_t server_version_minor;
81 bool version_compatible;
82 std::string server_identifier;
83 ores::utility::serialization::error_code status;
101 static std::expected<handshake_response, ores::utility::serialization::error_code>
109 ores::utility::serialization::error_code status;
119 static std::expected<handshake_ack, ores::utility::serialization::error_code>
132 std::uint32_t sequence,
133 const std::string& client_identifier,
134 std::uint8_t supported_compression = 0);
147 std::uint32_t sequence,
148 bool version_compatible,
149 const std::string& server_identifier,
150 ores::utility::serialization::error_code status = ores::utility::serialization::error_code::none,
157 std::uint32_t sequence,
158 ores::utility::serialization::error_code status = ores::utility::serialization::error_code::none);
169 std::uint32_t sequence,
170 std::uint32_t correlation_id,
171 ores::utility::serialization::error_code code,
172 const std::string& message);
185 std::uint8_t supported_compression,
195 static constexpr message_type request_message_type =
196 message_type::handshake_request;
Contains messaging related infrastructure in the comms library.
Definition assets_protocol.hpp:122
frame create_handshake_response_frame(std::uint32_t sequence, bool version_compatible, const std::string &server_identifier, ores::utility::serialization::error_code status=ores::utility::serialization::error_code::none, compression_type selected_compression=compression_type::none)
Create a handshake response frame.
frame create_error_response_frame(std::uint32_t sequence, std::uint32_t correlation_id, ores::utility::serialization::error_code code, const std::string &message)
Create an error response frame.
constexpr std::uint8_t COMPRESSION_SUPPORT_ZLIB
Compression support bitmask values.
Definition handshake_protocol.hpp:39
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:124
frame create_handshake_ack_frame(std::uint32_t sequence, ores::utility::serialization::error_code status=ores::utility::serialization::error_code::none)
Create a handshake acknowledgment frame.
compression_type
Compression algorithm used for payload compression.
Definition message_types.hpp:259
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:193
Complete frame with header and payload.
Definition frame.hpp:77
Handshake request message sent by client to initiate connection.
Definition handshake_protocol.hpp:47
static std::expected< handshake_request, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize from frame payload.
Definition handshake.cpp:53
static std::vector< std::byte > serialize(handshake_request v)
Serialize to frame payload.
Definition handshake.cpp:44
std::uint8_t supported_compression
Bitmask of compression types supported by the client.
Definition handshake_protocol.hpp:61
Handshake response message sent by server to client.
Definition handshake_protocol.hpp:78
static std::vector< std::byte > serialize(handshake_response v)
Serialize to frame payload.
Definition handshake.cpp:64
static std::expected< handshake_response, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize from frame payload.
Definition handshake.cpp:73
compression_type selected_compression
Compression type selected for this session.
Definition handshake_protocol.hpp:91
Handshake acknowledgment message sent by client to complete handshake.
Definition handshake_protocol.hpp:108
static std::expected< handshake_ack, ores::utility::serialization::error_code > deserialize(std::span< const std::byte > data)
Deserialize from frame payload.
Definition handshake.cpp:93
static std::vector< std::byte > serialize(handshake_ack v)
Serialize to frame payload.
Definition handshake.cpp:84
Traits template for mapping request types to their response types and message type enum values.
Definition message_traits.hpp:66