Skip to content

Commit

Permalink
Merge pull request #70 from ESTOS/feature/PROCALL-5827
Browse files Browse the repository at this point in the history
PROCALL-5827 add an option whether we want to log the transport data or not
  • Loading branch information
JanFellner authored Aug 14, 2024
2 parents 11a9eea + a2c683f commit a2cab08
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
8 changes: 4 additions & 4 deletions cpp-lib/include/SnaccROSEBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ class SnaccROSEBase : public SnaccROSESender
First call this function to complete pending invokes and if not processed
call OnBinaryDataBlock.
The data should be pure ASN.1 data without header.
The must be one call for each ROSEMessage. */
bool OnBinaryDataBlockResult(const char* lpBytes, unsigned long lSize);
There must be one call for each ROSEMessage.*/
bool OnBinaryDataBlockResult(const char* lpBytes, unsigned long lSize, bool bLogTransportData = true);

/*! Input of the binary data.
The data should be pure ASN.1 data without header.
The must be one call for each ROSEMessage. */
void OnBinaryDataBlock(const char* lpBytes, unsigned long lSize);
There must be one call for each ROSEMessage. */
void OnBinaryDataBlock(const char* lpBytes, unsigned long lSize, bool bLogTransportData = true);

/* Output of the binary data.
Override this function to send the data to the transport layer.
Expand Down
41 changes: 27 additions & 14 deletions cpp-lib/src/SnaccROSEBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ bool SnaccROSEBase::CompletePendingOperation(int invokeID, SNACC::ROSEMessage* p
return false;
}

bool SnaccROSEBase::OnBinaryDataBlockResult(const char* lpBytes, unsigned long lSize)
bool SnaccROSEBase::OnBinaryDataBlockResult(const char* lpBytes, unsigned long lSize, bool bLogTransportData /*= true */)
{
if (!lSize)
return false;
Expand All @@ -244,7 +244,8 @@ bool SnaccROSEBase::OnBinaryDataBlockResult(const char* lpBytes, unsigned long l
}
catch (const SnaccException& ex)
{
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);
if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);

SJson::Value error;
error["exception"] = ex.what();
Expand Down Expand Up @@ -272,7 +273,9 @@ bool SnaccROSEBase::OnBinaryDataBlockResult(const char* lpBytes, unsigned long l
delete pmessage;
return true;
}
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);

if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);

// pmessage will be deleted inside
bReturn = OnROSEMessage(pmessage, false);
Expand All @@ -296,7 +299,8 @@ bool SnaccROSEBase::OnBinaryDataBlockResult(const char* lpBytes, unsigned long l
}
catch (const SnaccException& ex)
{
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);
if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);

SJson::Value error;
error["exception"] = ex.what();
Expand Down Expand Up @@ -329,14 +333,16 @@ bool SnaccROSEBase::OnBinaryDataBlockResult(const char* lpBytes, unsigned long l
return true;
}

LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, pmessage, &value);
if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, pmessage, &value);

// pmessage will be deleted inside
bReturn = OnROSEMessage(pmessage, false);
}
else
{
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);
if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);

#ifdef _DEBUG
std::string strPayLoad;
Expand Down Expand Up @@ -423,7 +429,7 @@ std::string SnaccROSEBase::GetEncoded(const SNACC::TransportEncoding encoding, A
return strData;
}

void SnaccROSEBase::OnBinaryDataBlock(const char* lpBytes, unsigned long lSize)
void SnaccROSEBase::OnBinaryDataBlock(const char* lpBytes, unsigned long lSize, bool bLogTransportData /*= true*/)
{
if (!lSize)
return;
Expand All @@ -444,7 +450,8 @@ void SnaccROSEBase::OnBinaryDataBlock(const char* lpBytes, unsigned long lSize)
}
catch (const SnaccException& ex)
{
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);
if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);

SJson::Value error;
error["exception"] = ex.what();
Expand Down Expand Up @@ -473,7 +480,9 @@ void SnaccROSEBase::OnBinaryDataBlock(const char* lpBytes, unsigned long lSize)
delete pmessage;
return;
}
LogTransportData(false, SNACC::TransportEncoding::BER, nullptr, lpBytes, lSize, nullptr, nullptr);

if (bLogTransportData)
LogTransportData(false, SNACC::TransportEncoding::BER, nullptr, lpBytes, lSize, nullptr, nullptr);

// pmessage will be deleted inside
OnROSEMessage(pmessage, true);
Expand Down Expand Up @@ -503,7 +512,8 @@ void SnaccROSEBase::OnBinaryDataBlock(const char* lpBytes, unsigned long lSize)
}
catch (const SnaccException& ex)
{
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);
if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);

SJson::Value error;
error["exception"] = ex.what();
Expand Down Expand Up @@ -537,14 +547,17 @@ void SnaccROSEBase::OnBinaryDataBlock(const char* lpBytes, unsigned long lSize)
delete pmessage;
return;
}
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, pmessage, &value);

if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, pmessage, &value);

// pmessage will be deleted inside
OnROSEMessage(pmessage, true);
}
else
{
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);
if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);

SJson::Value error;
error["exception"] = reader.getFormattedErrorMessages();
Expand All @@ -569,8 +582,8 @@ void SnaccROSEBase::OnBinaryDataBlock(const char* lpBytes, unsigned long lSize)
}
else
{
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);

if (bLogTransportData)
LogTransportData(false, m_eTransportEncoding, nullptr, lpBytes, lSize, nullptr, nullptr);
OnRoseDecodeError(lpBytes, lSize, "unknown encoding");
}
}
Expand Down
6 changes: 3 additions & 3 deletions version.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef VERSION_H
#define VERSION_H

#define VERSION "6.0.9"
#define VERSION_RC 6, 0, 9
#define RELDATE "18.07.2024"
#define VERSION "6.0.10"
#define VERSION_RC 6, 0, 10
#define RELDATE "14.08.2024"

#endif // VERSION_H

0 comments on commit a2cab08

Please sign in to comment.