1 #ifndef TRANSPORT_RESPONSE_H 2 #define TRANSPORT_RESPONSE_H 9 std::memcpy(header, &PROTOCOL_VERS, Block::VersionProtocol);
12 virtual const void* get_data()
const override {
return __data; }
13 virtual void* get_data()
override {
return __data; }
15 virtual const char* get_login()
const {
27 std::memcpy(&roomid, __data + Block::LoginName,
sizeof(identifier_t));
31 virtual uint32_t get_length_data()
const override {
return LengthResponse;}
34 static constexpr
auto LengthResponse = Block::LoginName + Block::RoomId + Block::TextMessage;
35 char __data[LengthResponse];
42 std::memcpy(header+Block::VersionProtocol, &type_Response, Block::Command);
44 std::memcpy(__data+Block::LoginName, &roomid, Block::RoomId);
47 TextResponse(
const std::string& login,
const std::string& text, identifier_t roomid = 0) {
49 std::memcpy(header+Block::VersionProtocol, &type_Response, Block::Command);
50 std::snprintf(__data, Block::LoginName,
"%s", login.data());
51 std::memcpy(__data+Block::LoginName, &roomid, Block::RoomId);
52 std::snprintf(__data+Block::LoginName + Block::RoomId, Block::TextMessage,
"%s", text.data());
55 TextResponse(
const std::string& login,
DateTime dt,
const std::string& text, identifier_t roomid = 0) {
57 std::memcpy(header+Block::VersionProtocol, &type_Response, Block::Command);
58 std::memcpy(header+Block::VersionProtocol+Block::Command, &dt, Block::Datetime);
59 std::snprintf(__data, Block::LoginName,
"%s", login.data());
60 std::memcpy(__data+Block::LoginName, &roomid, Block::RoomId);
61 std::snprintf(__data+Block::LoginName + Block::RoomId, Block::TextMessage,
"%s", text.data());
65 std::memcpy(header, response->get_header(), Block::Header);
67 std::memset(__data+Block::LoginName, 0, Block::RoomId);
70 const char* get_message()
const {
71 return __data+Block::LoginName+Block::RoomId;
74 const TypeCommand type_Response = TypeCommand::EchoResponse;
77 using transport_response_ptr = std::shared_ptr<TransportResponse>;
78 using text_response_ptr = std::shared_ptr<TextResponse>;
80 #endif // TRANSPORT_RESPONSE_H
Definition: transport_response.h:38
virtual identifier_t get_roomid() const
Definition: transport_response.h:19
Definition: transport_response.h:6