From 0e59f2cd05fa9662dfc97c01677c8bbb407c9d7c Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 13 Sep 2024 16:02:43 -0700 Subject: [PATCH] [ntcore] Add StopRead/StartRead to WireConnection --- ntcore/src/main/native/cpp/net/WebSocketConnection.h | 4 ++++ ntcore/src/main/native/cpp/net/WireConnection.h | 3 +++ ntcore/src/main/native/cpp/net3/UvStreamConnection3.h | 4 ++++ ntcore/src/main/native/cpp/net3/WireConnection3.h | 3 +++ ntcore/src/test/native/cpp/net/MockWireConnection.h | 3 +++ ntcore/src/test/native/cpp/net3/MockWireConnection3.h | 3 +++ 6 files changed, 20 insertions(+) diff --git a/ntcore/src/main/native/cpp/net/WebSocketConnection.h b/ntcore/src/main/native/cpp/net/WebSocketConnection.h index fc5cfe98330..68102949e54 100644 --- a/ntcore/src/main/native/cpp/net/WebSocketConnection.h +++ b/ntcore/src/main/native/cpp/net/WebSocketConnection.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "WireConnection.h" @@ -58,6 +59,9 @@ class WebSocketConnection final return m_ws.GetLastReceivedTime(); } + void StopRead() final { m_ws.GetStream().StopRead(); } + void StartRead() final { m_ws.GetStream().StartRead(); } + void Disconnect(std::string_view reason) final; std::string_view GetDisconnectReason() const { return m_reason; } diff --git a/ntcore/src/main/native/cpp/net/WireConnection.h b/ntcore/src/main/native/cpp/net/WireConnection.h index c1efaff2f8c..a6ca1df1a32 100644 --- a/ntcore/src/main/native/cpp/net/WireConnection.h +++ b/ntcore/src/main/native/cpp/net/WireConnection.h @@ -54,6 +54,9 @@ class WireConnection { // Gets the timestamp of the last incoming data virtual uint64_t GetLastReceivedTime() const = 0; // in microseconds + virtual void StopRead() = 0; + virtual void StartRead() = 0; + virtual void Disconnect(std::string_view reason) = 0; }; diff --git a/ntcore/src/main/native/cpp/net3/UvStreamConnection3.h b/ntcore/src/main/native/cpp/net3/UvStreamConnection3.h index 35eef02fd5c..a27e04ada20 100644 --- a/ntcore/src/main/native/cpp/net3/UvStreamConnection3.h +++ b/ntcore/src/main/native/cpp/net3/UvStreamConnection3.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "net3/WireConnection3.h" @@ -40,6 +41,9 @@ class UvStreamConnection3 final uint64_t GetLastFlushTime() const final { return m_lastFlushTime; } + void StopRead() final { m_stream.StopRead(); } + void StartRead() final { m_stream.StartRead(); } + void Disconnect(std::string_view reason) final; std::string_view GetDisconnectReason() const { return m_reason; } diff --git a/ntcore/src/main/native/cpp/net3/WireConnection3.h b/ntcore/src/main/native/cpp/net3/WireConnection3.h index 0bb26f68865..0d62c8fc89a 100644 --- a/ntcore/src/main/native/cpp/net3/WireConnection3.h +++ b/ntcore/src/main/native/cpp/net3/WireConnection3.h @@ -30,6 +30,9 @@ class WireConnection3 { virtual uint64_t GetLastFlushTime() const = 0; // in microseconds + virtual void StopRead() = 0; + virtual void StartRead() = 0; + virtual void Disconnect(std::string_view reason) = 0; protected: diff --git a/ntcore/src/test/native/cpp/net/MockWireConnection.h b/ntcore/src/test/native/cpp/net/MockWireConnection.h index cc2d19b1715..60d446fa88c 100644 --- a/ntcore/src/test/native/cpp/net/MockWireConnection.h +++ b/ntcore/src/test/native/cpp/net/MockWireConnection.h @@ -65,6 +65,9 @@ class MockWireConnection : public WireConnection { MOCK_METHOD(uint64_t, GetLastFlushTime, (), (const, override)); MOCK_METHOD(uint64_t, GetLastReceivedTime, (), (const, override)); + MOCK_METHOD(void, StopRead, (), (override)); + MOCK_METHOD(void, StartRead, (), (override)); + MOCK_METHOD(void, Disconnect, (std::string_view reason), (override)); }; diff --git a/ntcore/src/test/native/cpp/net3/MockWireConnection3.h b/ntcore/src/test/native/cpp/net3/MockWireConnection3.h index 50fc80cbbba..f788df1b524 100644 --- a/ntcore/src/test/native/cpp/net3/MockWireConnection3.h +++ b/ntcore/src/test/native/cpp/net3/MockWireConnection3.h @@ -30,6 +30,9 @@ class MockWireConnection3 : public WireConnection3 { MOCK_METHOD(uint64_t, GetLastFlushTime, (), (const, override)); + MOCK_METHOD(void, StopRead, (), (override)); + MOCK_METHOD(void, StartRead, (), (override)); + MOCK_METHOD(void, Disconnect, (std::string_view reason), (override)); protected: