/*** Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: AuRPC.hpp Date: 2022-6-29 Author: Reece ***/ #pragma once struct Session; struct AuRPCServer; struct AuRPCServerChannel; struct AuRPCClientChannel; struct AuRPCRequest; struct AuRPC; struct AuRPCRequestCallback; struct AuIRPCService; #include "AuRPCAPI.hpp" #include #include "AuRPCServer.hpp" struct AuRPC : AuIRPC, AuEnableSharedFromThis { bool StartClient(AuAsync::WorkerPId_t worker) override; bool StartServer(AuAsync::WorkerPId_t worker) override; AuSPtr ToServer() override; AuSPtr Connect(const AuString &str); void SetRecommendedPipeLength(AuUInt32 uLength) override; private: friend struct AuRPCPipe; friend struct AuRPCServerChannel; AuOptional optPipeLength; AuAsync::WorkerPId_t pinnedClientThread; AuRPCServer server; AuList> clientChannels; }; AuSPtr GetRPCProcessor(); static const auto kRequestConnect = 1u; static const auto kRequestRPC = 2u; static const auto kResponseConnectOK = 10u; static const auto kResponseMulticonnect = 11u; static const auto kResponseRPC = 12u; static const auto kGeneralBroadcast = 20u; static const auto kGeneralClientMessage = 21u; // shared static const auto kGeneralServerMessage = 21u; // shared static const AuUInt8 kResponseError[512] = {0}; #if (defined(AU_CFG_ID_DEBUG) || defined(AU_CFG_ID_INTERNAL__) /*!!!*/) && !defined(AU_RPC_DEBUG) #define AU_RPC_DEBUG #endif #if defined(AU_RPC_DEBUG) #define RpcLogDebug AuLogDbg #else #define RpcLogDebug(...) #endif