diff --git a/shared/src/traintastic/network/message.hpp b/shared/src/traintastic/network/message.hpp index fffedf71..bc3c8148 100644 --- a/shared/src/traintastic/network/message.hpp +++ b/shared/src/traintastic/network/message.hpp @@ -3,7 +3,7 @@ * * This file is part of the traintastic source code. * - * Copyright (C) 2019-2024 Reinder Feenstra + * Copyright (C) 2019-2025 Reinder Feenstra * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -214,6 +214,30 @@ class Message { } + inline std::unique_ptr response(size_t capacity = 0) const + { + assert(isRequest()); + return newResponse(command(), requestId(), capacity); + } + + inline std::unique_ptr errorResponse(LogMessage code) const + { + assert(isRequest()); + return newErrorResponse(command(), requestId(), code); + } + + inline std::unique_ptr errorResponse(LogMessage code, std::string_view arg) const + { + assert(isRequest()); + return newErrorResponse(command(), requestId(), code, arg); + } + + inline std::unique_ptr errorResponse(LogMessage code, const std::vector& args) const + { + assert(isRequest()); + return newErrorResponse(command(), requestId(), code, args); + } + inline Command command() const { return header().command; } inline Type type() const { return static_cast(header().flags.type); } inline bool isRequest() const { return type() == Type::Request; }