2022-04-16 15:42:48 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
2022-12-14 05:03:37 +00:00
|
|
|
File: AuIPCPipe.NT.hpp
|
2022-04-16 15:42:48 +00:00
|
|
|
Date: 2022-4-15
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2022-06-22 20:24:04 +00:00
|
|
|
#include "IPC.hpp"
|
|
|
|
|
2022-12-14 05:03:37 +00:00
|
|
|
#include <Source/IO/IPC/AuIPCHandle.hpp>
|
2023-09-16 23:34:37 +00:00
|
|
|
#include <Source/IO/Loop/LSHandle.hpp>
|
|
|
|
|
2023-10-21 09:39:47 +00:00
|
|
|
#include "AuIPCPipeWriter.hpp"
|
|
|
|
#include "AuIPCPipeReader.hpp"
|
|
|
|
|
2023-09-16 23:34:37 +00:00
|
|
|
namespace Aurora::IO::FS
|
|
|
|
{
|
|
|
|
struct NtAsyncFileStream;
|
|
|
|
}
|
2022-06-22 20:24:04 +00:00
|
|
|
|
2022-06-11 23:52:46 +00:00
|
|
|
namespace Aurora::IO::IPC
|
2022-04-16 15:42:48 +00:00
|
|
|
{
|
2022-06-22 20:24:04 +00:00
|
|
|
struct IPCHasConnectionEvent;
|
|
|
|
struct IPCHandle;
|
|
|
|
|
2023-10-20 15:33:18 +00:00
|
|
|
struct IPCPipeImpl : IPCPipe,
|
|
|
|
Loop::LSHandle,
|
|
|
|
AuEnableSharedFromThis<IPCPipeImpl>
|
2022-06-22 20:24:04 +00:00
|
|
|
{
|
|
|
|
IPCPipeImpl(HANDLE clientHandle, HANDLE serverHandle, const IPCHandle &handle);
|
|
|
|
~IPCPipeImpl();
|
|
|
|
|
|
|
|
PROXY_INTERNAL_INTERFACE_(LSHandle::)
|
|
|
|
|
|
|
|
virtual AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() override;
|
2023-07-29 07:52:33 +00:00
|
|
|
virtual AuSPtr<IO::IIOHandle> GetCurrentSharedDuplexHandles() override;
|
2022-06-22 20:24:04 +00:00
|
|
|
|
|
|
|
virtual AuSPtr<Loop::ILoopSource> AsReadChannelIsOpen() override;
|
|
|
|
virtual AuSPtr<Loop::ILoopSource> AsReadChannelHasData() override;
|
|
|
|
|
|
|
|
virtual bool Read(const Memory::MemoryViewStreamWrite &write, bool nonblocking) override;
|
|
|
|
virtual bool Write(const Memory::MemoryViewStreamRead &read) override;
|
|
|
|
virtual AuString ExportToString() override;
|
|
|
|
|
2023-10-20 15:33:18 +00:00
|
|
|
virtual AuSPtr<IO::FS::IFileStream> ToFileStream() override;
|
|
|
|
virtual AuSPtr<IStreamReader> ToStreamReader() override;
|
|
|
|
virtual AuSPtr<IStreamWriter> ToStreamWriter() override;
|
|
|
|
|
2022-06-22 20:24:04 +00:00
|
|
|
bool IsSignaled() override;
|
|
|
|
bool WaitOn(AuUInt32 timeout) override;
|
|
|
|
Loop::ELoopSource GetType() override;
|
|
|
|
|
|
|
|
HANDLE GetPipeHandle();
|
|
|
|
HANDLE GetConnectHandle();
|
|
|
|
|
|
|
|
void OnEndOfReadStream();
|
|
|
|
|
|
|
|
void TryConnect();
|
|
|
|
OVERLAPPED overlapped {};
|
2022-07-21 06:18:53 +00:00
|
|
|
HANDLE clientHandle_ {INVALID_HANDLE_VALUE};
|
2022-04-16 15:42:48 +00:00
|
|
|
|
2023-12-16 21:08:46 +00:00
|
|
|
bool bDead {};
|
2022-06-22 20:24:04 +00:00
|
|
|
AuSPtr<Loop::ILSEvent> hasClient_;
|
|
|
|
private:
|
|
|
|
HANDLE serverHandle_ {INVALID_HANDLE_VALUE};
|
|
|
|
IPCHandle ipcHandle_;
|
2023-07-29 07:02:47 +00:00
|
|
|
AuSPtr<IO::IIOHandle> fsHandle_;
|
2022-06-22 20:24:04 +00:00
|
|
|
AuSPtr<IO::FS::NtAsyncFileStream> fsStream_;
|
|
|
|
AuSPtr<IPCHasConnectionEvent> lshasConnection_;
|
|
|
|
bool bFirstTime {true};
|
2023-10-20 15:33:18 +00:00
|
|
|
AuSPtr<IO::FS::IFileStream> fsBlockingStream_;
|
2023-10-21 09:39:47 +00:00
|
|
|
IPCPipeReader pipeReader_;
|
|
|
|
IPCPipeWriter pipeWriter_;
|
2022-06-22 20:24:04 +00:00
|
|
|
};
|
2022-04-16 15:42:48 +00:00
|
|
|
}
|