119 lines
11 KiB
C++
119 lines
11 KiB
C++
|
/***
|
||
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: BaseChannel.hpp
|
||
|
Date: 2022-2-1
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#pragma once
|
||
|
|
||
|
#include "PlatformChannel.hpp"
|
||
|
|
||
|
namespace Aurora::IO::Net
|
||
|
{
|
||
|
struct BaseSocket;
|
||
|
|
||
|
struct BaseChannel : public ISocketChannel
|
||
|
{
|
||
|
BaseChannel(BaseSocket *base) : base_(base), platform_(base)
|
||
|
{}
|
||
|
|
||
|
bool GetRemoteEndpoint(ConnectionEndpoint &out);
|
||
|
|
||
|
bool ReadAsync(const Memory::MemoryViewStreamWrite &memory, bool all) override;
|
||
|
bool PeekAsync(const Memory::MemoryViewStreamWrite &memory) override;
|
||
|
bool SeekAsync(int signedDistanceFromCur) override;
|
||
|
bool ReadSync(const Memory::MemoryViewStreamWrite &memory, bool all) override;
|
||
|
bool WriteAsync(const Memory::MemoryViewStreamRead &memory) override;
|
||
|
bool WriteAsync(const Memory::MemoryViewStreamRead &memory, AuUInt fence, const AuSPtr<ISocketSubmissionComplete> &input) override;
|
||
|
bool WriteSync(const Memory::MemoryViewStreamRead &memory) override;
|
||
|
|
||
|
AuUInt GetInternalInputRingBuffer() override;
|
||
|
bool SetInternalInputRingBuffer(AuUInt bytes) override;
|
||
|
|
||
|
void SetRecvLength(AuUInt32 length) override;
|
||
|
AuUInt32 GetRecvLength() override;
|
||
|
|
||
|
void BufferInputStreamAdhoc(bool value) override;
|
||
|
|
||
|
void ConfigureHasDataCallback(bool enabled) override;
|
||
|
|
||
|
void ReconfigureStreams(const StreamConfig &config) override;
|
||
|
|
||
|
private:
|
||
|
PlatformChannel platform_;
|
||
|
BaseSocket *base_;
|
||
|
};
|
||
|
|
||
|
#define IMPLEMENT_PLATFORM_PROXY(access) \
|
||
|
\
|
||
|
bool ReadAsync(const Memory::MemoryViewStreamWrite &memory, bool all) override \
|
||
|
{ \
|
||
|
return access ReadAsync(memory, all); \
|
||
|
} \
|
||
|
\
|
||
|
bool PeekAsync(const Memory::MemoryViewStreamWrite &memory) override \
|
||
|
{ \
|
||
|
return access PeekAsync(memory); \
|
||
|
} \
|
||
|
\
|
||
|
bool SeekAsync(int signedDistanceFromCur) override \
|
||
|
{ \
|
||
|
return access SeekAsync(signedDistanceFromCur); \
|
||
|
} \
|
||
|
\
|
||
|
bool ReadSync(const Memory::MemoryViewStreamWrite &memory, bool all) override \
|
||
|
{ \
|
||
|
return access ReadSync(memory, all); \
|
||
|
} \
|
||
|
\
|
||
|
bool WriteAsync(const Memory::MemoryViewStreamRead &memory) override \
|
||
|
{ \
|
||
|
return access WriteAsync(memory); \
|
||
|
} \
|
||
|
\
|
||
|
bool WriteAsync(const Memory::MemoryViewStreamRead &memory, AuUInt fence, const AuSPtr<ISocketSubmissionComplete> &input) override \
|
||
|
{ \
|
||
|
return access WriteAsync(memory, fence, input); \
|
||
|
} \
|
||
|
\
|
||
|
bool WriteSync(const Memory::MemoryViewStreamRead &memory) override \
|
||
|
{ \
|
||
|
return access WriteAsync(memory); \
|
||
|
} \
|
||
|
\
|
||
|
AuUInt GetInternalInputRingBuffer() override \
|
||
|
{ \
|
||
|
return access GetInternalInputRingBuffer(); \
|
||
|
} \
|
||
|
\
|
||
|
bool SetInternalInputRingBuffer(AuUInt bytes) override \
|
||
|
{ \
|
||
|
return access SetInternalInputRingBuffer(bytes); \
|
||
|
} \
|
||
|
\
|
||
|
void SetRecvLength(AuUInt32 length) override \
|
||
|
{ \
|
||
|
access SetRecvLength(length); \
|
||
|
} \
|
||
|
\
|
||
|
AuUInt32 GetRecvLength() override \
|
||
|
{ \
|
||
|
return access GetRecvLength(); \
|
||
|
} \
|
||
|
\
|
||
|
void BufferInputStreamAdhoc(bool value) override \
|
||
|
{ \
|
||
|
access BufferInputStreamAdhoc(value); \
|
||
|
} \
|
||
|
\
|
||
|
void ConfigureHasDataCallback(bool enabled) override \
|
||
|
{ \
|
||
|
access ConfigureHasDataCallback(enabled); \
|
||
|
} \
|
||
|
\
|
||
|
void ReconfigureStreams(const StreamConfig &config) override \
|
||
|
{ \
|
||
|
access ReconfigureStreams(config); \
|
||
|
}
|
||
|
}
|