[+] Future proof IProtocolInterceptorEx with an optional pParent in the only Aurora Interface methods last argument

This commit is contained in:
Reece Wilson 2023-06-10 20:33:19 +01:00
parent 90e08d534c
commit 4a584ce73a
8 changed files with 29 additions and 8 deletions

View File

@ -9,14 +9,29 @@
namespace Aurora::IO::Protocol
{
struct IProtocolPiece;
AUKN_INTERFACE(IProtocolInterceptorEx,
/**
* @brief
*
* @param pReadInByteBuffer a buffer to read from. returning false returns the readPtr of this buffer.
* @param pWriteOutByteBuffer a buffer to write into. you should return false if that buffer begins to fail.
* @param pProtocolStack A pointer that might be used to store user contexts. might be null. \
* This is only provided for convenience to users outside of Aurora Runtime. \
*
*
* @return false restores the read head of pReadInByteBuffer. future callbacks will still be made.
* true nothing; pReadInByteBuffer's heads will remain set by the user and the tick is propagated down the stack.
*
* @warning the error flags of both bytebuffers can seize up the protocol stack by design.
*
* @warning: Some interfaces permit arbitrary users to call OnDataAvailable.
* In fact, all Aurora Runtime (compress, TLS, etc) implementers should support out of protocol-stack support.
* This is an important detail to note: **pProtocolStack might be null**
*/
AUI_METHOD(bool, OnDataAvailable, (const AuSPtr<Memory::ByteBuffer> &, pReadInByteBuffer,
const AuSPtr<Memory::ByteBuffer> &, pWriteOutByteBuffer))
const AuSPtr<Memory::ByteBuffer> &, pWriteOutByteBuffer,
const AuSPtr<IProtocolPiece>&, pProtocolPiece))
);
}

View File

@ -53,7 +53,8 @@ namespace Aurora::Compression
}
bool CompressionInterceptor::OnDataAvailable(const AuSPtr<Memory::ByteBuffer> &pReadInByteBuffer,
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer)
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer,
const AuSPtr<IO::Protocol::IProtocolPiece> &pProtocolPiece)
{
this->pLastBuffer_ = pReadInByteBuffer;
this->pBaseStream_->SetWeakBuffer(pReadInByteBuffer);

View File

@ -19,7 +19,8 @@ namespace Aurora::Compression
const AuSPtr<BaseStream> &pBaseStream);
bool OnDataAvailable(const AuSPtr<Memory::ByteBuffer> &pReadInByteBuffer,
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer) override;
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer,
const AuSPtr<IO::Protocol::IProtocolPiece> &pProtocolPiece) override;
inline virtual IO::EStreamError IsOpen() override;

View File

@ -597,7 +597,7 @@ namespace Aurora::IO::Protocol
}
}
if (!pCurrent->pInterceptorEx->OnDataAvailable(pRead, pNextStream))
if (!pCurrent->pInterceptorEx->OnDataAvailable(pRead, pNextStream, pCurrent))
{
if (pNextStream)
{

View File

@ -16,7 +16,8 @@ namespace Aurora::IO::TLS
}
bool TLSProtocolRecv::OnDataAvailable(const AuSPtr<Memory::ByteBuffer> &pReadInByteBuffer,
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer)
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer,
const AuSPtr<Protocol::IProtocolPiece> &pProtocolPiece)
{
this->bHasRead = false;
this->pReadInByteBuffer = pReadInByteBuffer;

View File

@ -16,7 +16,8 @@ namespace Aurora::IO::TLS
TLSProtocolRecv(TLSContext *pParent);
virtual bool OnDataAvailable(const AuSPtr<Memory::ByteBuffer> &pReadInByteBuffer,
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer) override;
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer,
const AuSPtr<Protocol::IProtocolPiece> &pProtocolPiece) override;
bool TryHandshake();

View File

@ -16,7 +16,8 @@ namespace Aurora::IO::TLS
}
bool TLSProtocolSend::OnDataAvailable(const AuSPtr<Memory::ByteBuffer> &pReadInByteBuffer,
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer)
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer,
const AuSPtr<Protocol::IProtocolPiece> &pProtocolPiece)
{
if (!this->pParent_->bIsAlive)
{

View File

@ -16,7 +16,8 @@ namespace Aurora::IO::TLS
TLSProtocolSend(TLSContext *pParent);
virtual bool OnDataAvailable(const AuSPtr<Memory::ByteBuffer> &pReadInByteBuffer,
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer) override;
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer,
const AuSPtr<Protocol::IProtocolPiece> &pProtocolPiece) override;
private: