@@ -30,6 +30,7 @@ public class ShdrClient
3030 private TcpClient _client ;
3131 private long _lastHeartbeat = 0 ;
3232 private CancellationTokenSource _stop ;
33+ private int _heartbeat = DefaultPongHeartbeat ;
3334
3435
3536 /// <summary>
@@ -195,7 +196,6 @@ private async Task ListenForAdapter(CancellationToken cancel)
195196 var reconnectInterval = Math . Max ( ReconnectInterval , 100 ) ;
196197 var connected = false ;
197198
198- var heartbeat = DefaultPongHeartbeat ;
199199 long lastResponse = 0 ;
200200 long now = UnixDateTime . Now ;
201201
@@ -254,7 +254,7 @@ private async Task ListenForAdapter(CancellationToken cancel)
254254 }
255255
256256 // 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 ) )
258258 {
259259 messageBytes = Encoding . ASCII . GetBytes ( PingMessage ) ;
260260 stream . Write ( messageBytes , 0 , messageBytes . Length ) ;
@@ -339,7 +339,6 @@ private bool ProcessResponse(ref char[] chars, int length)
339339 if ( lines != null && lines . Length > 0 )
340340 {
341341 var j = 0 ;
342- int heartbeat ;
343342
344343 bool multilineAsset = false ;
345344 long multilineAssetTimestamp = 0 ;
@@ -365,9 +364,9 @@ private bool ProcessResponse(ref char[] chars, int length)
365364 {
366365 if ( line . StartsWith ( "* PONG" ) )
367366 {
368- heartbeat = GetPongHeartbeat ( line ) ;
367+ _heartbeat = GetPongHeartbeat ( line ) ;
369368
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") ;
371370 }
372371 else
373372 {
0 commit comments