@@ -30,6 +30,7 @@ public class ShdrClient
30
30
private TcpClient _client ;
31
31
private long _lastHeartbeat = 0 ;
32
32
private CancellationTokenSource _stop ;
33
+ private int _heartbeat = DefaultPongHeartbeat ;
33
34
34
35
35
36
/// <summary>
@@ -195,7 +196,6 @@ private async Task ListenForAdapter(CancellationToken cancel)
195
196
var reconnectInterval = Math . Max ( ReconnectInterval , 100 ) ;
196
197
var connected = false ;
197
198
198
- var heartbeat = DefaultPongHeartbeat ;
199
199
long lastResponse = 0 ;
200
200
long now = UnixDateTime . Now ;
201
201
@@ -254,7 +254,7 @@ private async Task ListenForAdapter(CancellationToken cancel)
254
254
}
255
255
256
256
// Send PING Heartbeat if needed
257
- if ( ( now - lastResponse ) > heartbeat * 10000 && ( now - _lastHeartbeat ) > heartbeat * 10000 )
257
+ if ( ( ( now - lastResponse ) > _heartbeat * 10000 ) && ( ( now - _lastHeartbeat ) > _heartbeat * 10000 ) )
258
258
{
259
259
messageBytes = Encoding . ASCII . GetBytes ( PingMessage ) ;
260
260
stream . Write ( messageBytes , 0 , messageBytes . Length ) ;
@@ -339,7 +339,6 @@ private bool ProcessResponse(ref char[] chars, int length)
339
339
if ( lines != null && lines . Length > 0 )
340
340
{
341
341
var j = 0 ;
342
- int heartbeat ;
343
342
344
343
bool multilineAsset = false ;
345
344
long multilineAssetTimestamp = 0 ;
@@ -365,9 +364,9 @@ private bool ProcessResponse(ref char[] chars, int length)
365
364
{
366
365
if ( line . StartsWith ( "* PONG" ) )
367
366
{
368
- heartbeat = GetPongHeartbeat ( line ) ;
367
+ _heartbeat = GetPongHeartbeat ( line ) ;
369
368
370
- PongReceived ? . Invoke ( this , $ "PONG Received from : { Hostname } on Port { Port } : Heartbeat = { heartbeat } ms") ;
369
+ PongReceived ? . Invoke ( this , $ "PONG Received from : { Hostname } on Port { Port } : Heartbeat = { _heartbeat } ms") ;
371
370
}
372
371
else
373
372
{
0 commit comments