/*
 * This RPC client stub was autogenerated by idlc (version c8601c6e). DO NOT EDIT!
 * Generated from WindowServer.idl for interface WindowServer at 2021-07-11T18:46:48-0500
 *
 * You may use these generated stubs directly as the RPC interface, or you can subclass it to
 * override the behavior of the function calls, or to perform some preprocessing to the data as
 * needed before sending it.
 *
 * See the full RPC documentation for more details.
 */
#ifndef RPC_CLIENT_GENERATED_16174174863144938629
#define RPC_CLIENT_GENERATED_16174174863144938629

#include <string>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <span>
#include <string_view>
#include <vector>

namespace rpc {
namespace rt { class ClientRpcIoStream; }
class WindowServerClient {
    struct MessageHeader {
        enum Flags: uint32_t {
            Request                     = (1 << 0),
            Response                    = (1 << 1),
        };

        uint64_t type;
        Flags flags;
        uint32_t tag;

        std::byte payload[];
    };
    static_assert(!(offsetof(MessageHeader, payload) % sizeof(uintptr_t)),
        "message header's payload is not word aligned");

    constexpr static const std::string_view kServiceName{"WindowServer"};

    protected:
        using IoStream = rt::ClientRpcIoStream;

    public:

    public:
        WindowServerClient(const std::shared_ptr<IoStream> &stream);
        virtual ~WindowServerClient();

        virtual void SubmitKeyEvent(uint32_t scancode, bool release);
        virtual void SubmitMouseEvent(uint32_t buttons, int32_t dX, int32_t dY, int32_t dZ);

    // Helpers provided to subclasses for implementation of interface methods
    protected:
        constexpr inline auto &getIo() {
            return this->io;
        }

        /// Handles errors occurring during client operations; typically terminates the task
        virtual void _HandleError(const bool fatal, const std::string_view &what);

    // Implementation details; pretend this does not exist
    private:
        std::shared_ptr<IoStream> io;
        size_t txBufSize{0};
        void *txBuf{nullptr};

        uint32_t nextTag{0};

        void _ensureTxBuf(const size_t);
        uint32_t _sendRequest(const uint64_t type, const size_t payloadBytes);
}; // class WindowServerClient
} // namespace rpc
#endif // defined(RPC_CLIENT_GENERATED_16174174863144938629)
