Skip to content

Commit c95a677

Browse files
committed
Change to use scheduleWithFixedDelay
1 parent 98c157e commit c95a677

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/AndroidClient/android/src/main/java/net/servicestack/client/sse/ServerEventsClient.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,12 @@ private void startNewHeartbeat() {
573573
if (heartbeatTimer == null)
574574
heartbeatTimer = new ScheduledThreadPoolExecutor(1);
575575

576-
heartbeatTimer.schedule(new Runnable() {
576+
heartbeatTimer.scheduleWithFixedDelay(new Runnable() {
577577
@Override
578578
public void run() {
579579
Heartbeat();
580580
}
581-
}, connectionInfo.getHeartbeatIntervalMs(), TimeUnit.MILLISECONDS);
581+
}, connectionInfo.getHeartbeatIntervalMs(), connectionInfo.getHeartbeatIntervalMs(), TimeUnit.MILLISECONDS);
582582
}
583583

584584
public void Heartbeat(){
@@ -621,8 +621,6 @@ public void Heartbeat(){
621621
if (Log.isDebugEnabled())
622622
Log.d("[SSE-CLIENT] Heartbeat sent to: " + heartbeatUrl);
623623

624-
startNewHeartbeat();
625-
626624
} catch (Exception e) {
627625
if (Log.isDebugEnabled())
628626
Log.d("[SSE-CLIENT] Error from Heartbeat: " + e);

src/AndroidClient/client/src/main/java/net/servicestack/client/sse/ServerEventsClient.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,12 @@ private void startNewHeartbeat() {
573573
if (heartbeatTimer == null)
574574
heartbeatTimer = new ScheduledThreadPoolExecutor(1);
575575

576-
heartbeatTimer.schedule(new Runnable() {
576+
heartbeatTimer.scheduleWithFixedDelay(new Runnable() {
577577
@Override
578578
public void run() {
579579
Heartbeat();
580580
}
581-
}, connectionInfo.getHeartbeatIntervalMs(), TimeUnit.MILLISECONDS);
581+
}, connectionInfo.getHeartbeatIntervalMs(), connectionInfo.getHeartbeatIntervalMs(), TimeUnit.MILLISECONDS);
582582
}
583583

584584
public void Heartbeat(){
@@ -621,8 +621,6 @@ public void Heartbeat(){
621621
if (Log.isDebugEnabled())
622622
Log.d("[SSE-CLIENT] Heartbeat sent to: " + heartbeatUrl);
623623

624-
startNewHeartbeat();
625-
626624
} catch (Exception e) {
627625
if (Log.isDebugEnabled())
628626
Log.d("[SSE-CLIENT] Error from Heartbeat: " + e);

0 commit comments

Comments
 (0)