69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
/***
|
|
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 <Aurora/IO/IOExperimental.hpp>
|
|
|
|
#include "AuRPCServer.hpp"
|
|
|
|
struct AuRPC : AuIRPC, AuEnableSharedFromThis<AuRPC>
|
|
{
|
|
bool StartClient(AuAsync::WorkerPId_t worker) override;
|
|
bool StartServer(AuAsync::WorkerPId_t worker) override;
|
|
|
|
AuSPtr<AuIRPCServer> ToServer() override;
|
|
AuSPtr<AuIRPCClientChannel> Connect(const AuString &str);
|
|
void SetRecommendedPipeLength(AuUInt32 uLength) override;
|
|
|
|
AuUInt32 GetLargePacketLength();
|
|
|
|
private:
|
|
friend struct AuRPCPipe;
|
|
friend struct AuRPCServerChannel;
|
|
|
|
AuOptional<AuUInt32> optPipeLength;
|
|
AuAsync::WorkerPId_t pinnedClientThread;
|
|
AuRPCServer server;
|
|
AuList<AuSPtr<AuRPCClientChannel>> clientChannels;
|
|
};
|
|
|
|
AuSPtr<AuIO::IIOProcessor> 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 auto kGeneralMassiveMessage = 22u;
|
|
|
|
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 |