Experimental AuroraRuntime-based Remote Procedure Call library
Go to file
Reece Wilson 14ebab9d22 [+] AuIRPCRequest::EmptyRequest()
[*] De boog numero 2
> Constrain dispatch bytebuffer views to the exact frame length
2022-07-07 05:16:27 +01:00
Include [+] AuIRPCRequest::EmptyRequest() 2022-07-07 05:16:27 +01:00
Source [+] AuIRPCRequest::EmptyRequest() 2022-07-07 05:16:27 +01:00
.gitignore Initial Commit 2022-07-02 23:13:53 +01:00
Aurora.json Initial Commit 2022-07-02 23:13:53 +01:00
LICENSE Initial Commit 2022-07-02 23:13:53 +01:00
README.md Initial Commit 2022-07-02 23:13:53 +01:00

Experimental RPC library

Example

#include <AuRPCAPI.hpp>

static AuSPtr<AuIRPC> gRpcServer = AuRPCNewInstance();
static AuSPtr<AuIRPC> gRpcClient = AuRPCNewInstance();
static AuSPtr<AuIRPCClientChannel> gRpcClientChannel;

void Run()
{
    SysAssert(gRpcServer->StartServer(AuAsync::GetCurrentWorkerPId()));
    SysAssert(gRpcClient->StartClient(AuAsync::GetCurrentWorkerPId()));

    auto server = gRpcServer->ToServer();

    auto handle = server->ExportString();

    struct DummyService : AuIRPCService
    {
        AuUInt32 GetId() override
        {
            return 2;
        }

        void Dispatch(AuRPCResponse &response, AuUInt32 id, AuByteBuffer &buffer) override
        {
            AuLogDbg("ID = {}, bytes = {}", id, buffer.RemainingBytes());
            
            response.message->Write<AuString>("Hello World");
        }
    };

    server->RegisterService(AuMakeShared<DummyService>());

    gRpcClientChannel = gRpcClient->Connect(handle);
    SysAssert(gRpcClientChannel);

    auto callback = AuMakeShared<AuIRPCChannelCallbacksFunctional>();
    SysAssert(callback);

    callback->OnConnectFunctional = []()
    {
        auto request = AuRPCNewRequest(2, 3);
        SysAssert(request);

        auto callback = AuMakeShared<AuRPCRequestCallbackFunctional>();
        SysAssert(callback);

        callback->OnResponseFunctional = [](const AuRPCResponse &res)
        {
            AuLogDbg("Complete! Message = {}", res.message->Read<AuString>());
        };

        request->SetCallback(callback);
        gRpcClientChannel->SendRequest(request);
    };

    gRpcClientChannel->SetCallbacks(callback);
}

Linux IO is lagging behind