Skip to content

Commit 59bc53b

Browse files
authored
[ntcore] Add StopRead/StartRead to WireConnection (#7188)
1 parent 94c62ed commit 59bc53b

File tree

6 files changed

+20
-0
lines changed

6 files changed

+20
-0
lines changed

ntcore/src/main/native/cpp/net/WebSocketConnection.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <wpi/function_ref.h>
1313
#include <wpinet/WebSocket.h>
1414
#include <wpinet/uv/Buffer.h>
15+
#include <wpinet/uv/Stream.h>
1516

1617
#include "WireConnection.h"
1718

@@ -58,6 +59,9 @@ class WebSocketConnection final
5859
return m_ws.GetLastReceivedTime();
5960
}
6061

62+
void StopRead() final { m_ws.GetStream().StopRead(); }
63+
void StartRead() final { m_ws.GetStream().StartRead(); }
64+
6165
void Disconnect(std::string_view reason) final;
6266

6367
std::string_view GetDisconnectReason() const { return m_reason; }

ntcore/src/main/native/cpp/net/WireConnection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class WireConnection {
5454
// Gets the timestamp of the last incoming data
5555
virtual uint64_t GetLastReceivedTime() const = 0; // in microseconds
5656

57+
virtual void StopRead() = 0;
58+
virtual void StartRead() = 0;
59+
5760
virtual void Disconnect(std::string_view reason) = 0;
5861
};
5962

ntcore/src/main/native/cpp/net3/UvStreamConnection3.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <wpi/SmallVector.h>
1313
#include <wpinet/raw_uv_ostream.h>
1414
#include <wpinet/uv/Buffer.h>
15+
#include <wpinet/uv/Stream.h>
1516

1617
#include "net3/WireConnection3.h"
1718

@@ -40,6 +41,9 @@ class UvStreamConnection3 final
4041

4142
uint64_t GetLastFlushTime() const final { return m_lastFlushTime; }
4243

44+
void StopRead() final { m_stream.StopRead(); }
45+
void StartRead() final { m_stream.StartRead(); }
46+
4347
void Disconnect(std::string_view reason) final;
4448

4549
std::string_view GetDisconnectReason() const { return m_reason; }

ntcore/src/main/native/cpp/net3/WireConnection3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class WireConnection3 {
3030

3131
virtual uint64_t GetLastFlushTime() const = 0; // in microseconds
3232

33+
virtual void StopRead() = 0;
34+
virtual void StartRead() = 0;
35+
3336
virtual void Disconnect(std::string_view reason) = 0;
3437

3538
protected:

ntcore/src/test/native/cpp/net/MockWireConnection.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class MockWireConnection : public WireConnection {
6565
MOCK_METHOD(uint64_t, GetLastFlushTime, (), (const, override));
6666
MOCK_METHOD(uint64_t, GetLastReceivedTime, (), (const, override));
6767

68+
MOCK_METHOD(void, StopRead, (), (override));
69+
MOCK_METHOD(void, StartRead, (), (override));
70+
6871
MOCK_METHOD(void, Disconnect, (std::string_view reason), (override));
6972
};
7073

ntcore/src/test/native/cpp/net3/MockWireConnection3.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class MockWireConnection3 : public WireConnection3 {
3030

3131
MOCK_METHOD(uint64_t, GetLastFlushTime, (), (const, override));
3232

33+
MOCK_METHOD(void, StopRead, (), (override));
34+
MOCK_METHOD(void, StartRead, (), (override));
35+
3336
MOCK_METHOD(void, Disconnect, (std::string_view reason), (override));
3437

3538
protected:

0 commit comments

Comments
 (0)