// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include #include #include #include #include #if ZEN_PLATFORM_WINDOWS # undef SendMessage #endif namespace zen::horde { /** Abstract base interface for compute transports. * * Matches the UE FComputeTransport pattern. Concrete implementations handle * the underlying I/O (TCP, AES-wrapped, etc.) while this interface provides * blocking message helpers on top. */ class ComputeTransport { public: virtual ~ComputeTransport() = default; virtual bool IsValid() const = 0; virtual size_t Send(const void* Data, size_t Size) = 0; virtual size_t Recv(void* Data, size_t Size) = 0; virtual void MarkComplete() = 0; virtual void Close() = 0; /** Blocking send that loops until all bytes are transferred. Returns false on error. */ bool SendMessage(const void* Data, size_t Size); /** Blocking receive that loops until all bytes are transferred. Returns false on error. */ bool RecvMessage(void* Data, size_t Size); }; /** TCP socket transport using ASIO. * * Connects to the Horde compute endpoint specified by MachineInfo and provides * raw TCP send/receive. ASIO internals are hidden behind a pimpl to keep the * header clean. */ class TcpComputeTransport final : public ComputeTransport { public: explicit TcpComputeTransport(const MachineInfo& Info); ~TcpComputeTransport() override; bool IsValid() const override; size_t Send(const void* Data, size_t Size) override; size_t Recv(void* Data, size_t Size) override; void MarkComplete() override; void Close() override; private: LoggerRef Log() { return m_Log; } struct Impl; std::unique_ptr m_Impl; LoggerRef m_Log; bool m_IsClosed = false; bool m_HasErrors = false; }; } // namespace zen::horde