/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: TLSProtocolSend.cpp
Date: 2022-8-24
Author: Reece
***/
#include "TLS.hpp"
#include "TLSContext.hpp"
namespace Aurora::IO::TLS
{
TLSProtocolSend::TLSProtocolSend(TLSContext *pParent) :
pParent_(pParent)
}
bool TLSProtocolSend::OnDataAvailable(const AuSPtr<Memory::ByteBuffer> &pReadInByteBuffer,
const AuSPtr<Memory::ByteBuffer> &pWriteOutByteBuffer,
const AuSPtr<Protocol::IProtocolPiece> &pProtocolPiece)
if (!this->pParent_->bIsAlive)
return true;
if (pReadInByteBuffer->writePtr == pReadInByteBuffer->readPtr)
while (pReadInByteBuffer->writePtr != pReadInByteBuffer->readPtr)
auto pDest = pReadInByteBuffer->GetNextLinearRead();
const AuUInt8 *pBase { pDest.ToPointer() };
AuUInt uCount { pDest.length };
if (!uCount)
int iRet = ::mbedtls_ssl_write(&this->pParent_->ssl,
pBase,
uCount);
if ((iRet == MBEDTLS_ERR_SSL_WANT_READ) ||
(iRet == MBEDTLS_ERR_SSL_WANT_WRITE))
if (iRet < 0)
this->pParent_->iFatalError = iRet;
SysPushErrorNet("{}", iRet);
this->pParent_->OnFatal();
return false;
pReadInByteBuffer->readPtr += iRet;