48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AuRPCClientChannel.hpp
|
|
Date: 2022-6-29
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include "AuRPCChannel.hpp"
|
|
#include "AuRPCPipe.hpp"
|
|
|
|
struct AuRPCClientChannel : AuRPCChannel, AuIRPCClientChannel, AuEnableSharedFromThis<AuRPCClientChannel>
|
|
{
|
|
AuRPCClientChannel(AuSPtr<AuRPC> parent) : parent_(parent), pipe_(this)
|
|
{
|
|
}
|
|
|
|
bool Init(const AuString& ipc);
|
|
void Finalize();
|
|
|
|
void Disconnect() override;
|
|
void SendRequest(AuSPtr<AuIRPCRequest> response) override;
|
|
|
|
void FatalIOError();
|
|
|
|
virtual AuSPtr<AuRPC> ToContext() override;
|
|
virtual bool OnConnect() override;
|
|
virtual void OnDisconnect(bool error) override;
|
|
virtual bool OnDataAvailable(AuByteBuffer& view) override;
|
|
|
|
void ProcessConnectionOK();
|
|
void ProcessResponse(const AuSPtr<AuRPCResponse>& response);
|
|
|
|
AuList<AuSPtr<AuRPCRequest>> outstandingRequests;
|
|
|
|
virtual bool IsConnected() override;
|
|
virtual void SetCallbacks(const AuSPtr<AuIRPCChannelCallbacks> &callbacks) override;
|
|
|
|
|
|
private:
|
|
bool bConnectingAlternate_{};
|
|
bool bConnected_{};
|
|
bool bIsDead_ {};
|
|
AuSPtr<AuIRPCChannelCallbacks> callbacks_;
|
|
AuRPCPipe pipe_;
|
|
AuSPtr<AuRPC> parent_;
|
|
}; |