File tree 2 files changed +26
-4
lines changed
ntcore/src/main/native/cpp
2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -59,8 +59,18 @@ class WebSocketConnection final
59
59
return m_ws.GetLastReceivedTime ();
60
60
}
61
61
62
- void StopRead () final { m_ws.GetStream ().StopRead (); }
63
- void StartRead () final { m_ws.GetStream ().StartRead (); }
62
+ void StopRead () final {
63
+ if (m_readActive) {
64
+ m_ws.GetStream ().StopRead ();
65
+ m_readActive = false ;
66
+ }
67
+ }
68
+ void StartRead () final {
69
+ if (!m_readActive) {
70
+ m_ws.GetStream ().StartRead ();
71
+ m_readActive = true ;
72
+ }
73
+ }
64
74
65
75
void Disconnect (std::string_view reason) final ;
66
76
@@ -80,6 +90,7 @@ class WebSocketConnection final
80
90
81
91
wpi::WebSocket& m_ws;
82
92
wpi::Logger& m_logger;
93
+ bool m_readActive = true ;
83
94
84
95
class Stream ;
85
96
Original file line number Diff line number Diff line change @@ -41,8 +41,18 @@ class UvStreamConnection3 final
41
41
42
42
uint64_t GetLastFlushTime () const final { return m_lastFlushTime; }
43
43
44
- void StopRead () final { m_stream.StopRead (); }
45
- void StartRead () final { m_stream.StartRead (); }
44
+ void StopRead () final {
45
+ if (m_readActive) {
46
+ m_stream.StopRead ();
47
+ m_readActive = false ;
48
+ }
49
+ }
50
+ void StartRead () final {
51
+ if (!m_readActive) {
52
+ m_stream.StartRead ();
53
+ m_readActive = true ;
54
+ }
55
+ }
46
56
47
57
void Disconnect (std::string_view reason) final ;
48
58
@@ -62,6 +72,7 @@ class UvStreamConnection3 final
62
72
std::string m_reason;
63
73
uint64_t m_lastFlushTime = 0 ;
64
74
int m_sendsActive = 0 ;
75
+ bool m_readActive = true ;
65
76
};
66
77
67
78
} // namespace nt::net3
You can’t perform that action at this time.
0 commit comments