AuroraRPC/Source/AuRPCServerChannel.hpp

56 lines
1.3 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuRPCServerChannel.hpp
Date: 2022-6-29
Author: Reece
***/
#pragma once
#include "AuRPCChannel.hpp"
#include "AuRPCPipe.hpp"
struct AuRPCServerChannel :
AuRPCChannel,
AuIRPCSession,
AuEnableSharedFromThis<AuRPCServerChannel>
{
AuRPCServerChannel(AuSPtr<AuRPC> parent, AuSPtr<AuRPCServer> server);
~AuRPCServerChannel();
bool Init();
AuString ExportString();
void SendResponse(AuSPtr<AuRPCResponse> response);
virtual AuSPtr<AuRPC> ToContext() override;
virtual bool OnConnect() override;
virtual void OnDisconnect(bool error) override;
virtual bool OnDataAvailable(AuByteBuffer& view) override;
virtual AuUInt64 GetConnectTimeNS() override;
virtual bool SendMessage(const AuMemoryViewRead &view, bool bLarge) override;
void FatalError();
void SendToNewChannel();
void SendConnectOK();
inline void MakeTemp()
{
this->isTempChannel_ = true;
}
void RemoveFromParent();
private:
friend struct AuRPCServer;
AuList<AuSPtr<AuRPCServerChannel>> subchannels_;
AuSPtr<AuRPCServer> server_;
bool isTempChannel_ {};
AuRPCPipe pipe;
AuUInt64 uConnectTime_ {};
AuSPtr<AuRPC> parent;
};