AuroraRPC/Source/AuRPC.hpp
2022-07-02 23:13:53 +01:00

59 lines
1.4 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);
bool StartServer(AuAsync::WorkerPId_t worker);
AuSPtr<AuIRPCServer> ToServer();
AuSPtr<AuIRPCClientChannel> Connect(const AuString& str);
private:
AuAsync::WorkerPId_t pinnedClientThread;
AuRPCServer server;
AuList<AuSPtr<AuRPCClientChannel>> clientChannels;
};
AuSPtr<AuIO::IIOProcessor> GetRPCProcessor();
static const auto kRequestConnect = 1;
static const auto kRequestRPC = 2;
static const auto kResponseConnectOK = 10;
static const auto kResponseMulticonnect = 11;
static const auto kResponseRPC = 12;
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