summaryrefslogtreecommitdiffstats
path: root/tests/Network/Google.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-01-22 13:00:32 +0100
committerMattes D <github@xoft.cz>2015-01-22 20:13:06 +0100
commitdbf7f13bd414daea5e787da2543df186dc465c34 (patch)
treec6ca36fcd22b422b89222a8c29beb046e70b4de6 /tests/Network/Google.cpp
parentcNetwork: Changed listening API. (diff)
downloadcuberite-dbf7f13bd414daea5e787da2543df186dc465c34.tar
cuberite-dbf7f13bd414daea5e787da2543df186dc465c34.tar.gz
cuberite-dbf7f13bd414daea5e787da2543df186dc465c34.tar.bz2
cuberite-dbf7f13bd414daea5e787da2543df186dc465c34.tar.lz
cuberite-dbf7f13bd414daea5e787da2543df186dc465c34.tar.xz
cuberite-dbf7f13bd414daea5e787da2543df186dc465c34.tar.zst
cuberite-dbf7f13bd414daea5e787da2543df186dc465c34.zip
Diffstat (limited to '')
-rw-r--r--tests/Network/Google.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/tests/Network/Google.cpp b/tests/Network/Google.cpp
index be08f179c..8985eef17 100644
--- a/tests/Network/Google.cpp
+++ b/tests/Network/Google.cpp
@@ -49,24 +49,39 @@ class cDumpCallbacks:
public cTCPLink::cCallbacks
{
cEvent & m_Event;
+ cTCPLinkPtr m_Link;
- virtual void OnReceivedData(cTCPLink & a_Link, const char * a_Data, size_t a_Size) override
+ virtual void OnLinkCreated(cTCPLinkPtr a_Link) override
{
+ ASSERT(m_Link == nullptr);
+ m_Link = a_Link;
+ }
+
+ virtual void OnReceivedData(const char * a_Data, size_t a_Size) override
+ {
+ ASSERT(m_Link != nullptr);
+
// Log the incoming data size:
AString Hex;
CreateHexDump(Hex, a_Data, a_Size, 16);
LOGD("Incoming data: %u bytes:\n%s", static_cast<unsigned>(a_Size), Hex.c_str());
}
- virtual void OnRemoteClosed(cTCPLink & a_Link) override
+ virtual void OnRemoteClosed(void) override
{
+ ASSERT(m_Link != nullptr);
+
LOGD("Remote has closed the connection.");
+ m_Link.reset();
m_Event.Set();
}
- virtual void OnError(cTCPLink & a_Link, int a_ErrorCode, const AString & a_ErrorMsg) override
+ virtual void OnError(int a_ErrorCode, const AString & a_ErrorMsg) override
{
+ ASSERT(m_Link != nullptr);
+
LOGD("Error %d (%s) in the cDumpCallbacks.", a_ErrorCode, a_ErrorMsg.c_str());
+ m_Link.reset();
m_Event.Set();
}