aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/schedule/TaskWebSocketKeepalive.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-11 15:04:51 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-11 15:04:51 -0700
commit7c08991f12b4958135fdffc26f272677c03630ad (patch)
treec1111ec78bad1dd8b0e4eb8f0c9194095d154d57 /src/main/java/org/traccar/schedule/TaskWebSocketKeepalive.java
parent4025a42c42e34bb620f4263de05781a10ddc7a9d (diff)
downloadtrackermap-server-7c08991f12b4958135fdffc26f272677c03630ad.tar.gz
trackermap-server-7c08991f12b4958135fdffc26f272677c03630ad.tar.bz2
trackermap-server-7c08991f12b4958135fdffc26f272677c03630ad.zip
Inject network client
Diffstat (limited to 'src/main/java/org/traccar/schedule/TaskWebSocketKeepalive.java')
-rw-r--r--src/main/java/org/traccar/schedule/TaskWebSocketKeepalive.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/main/java/org/traccar/schedule/TaskWebSocketKeepalive.java b/src/main/java/org/traccar/schedule/TaskWebSocketKeepalive.java
index 953b0efea..e6c2e8b6d 100644
--- a/src/main/java/org/traccar/schedule/TaskWebSocketKeepalive.java
+++ b/src/main/java/org/traccar/schedule/TaskWebSocketKeepalive.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2021 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,22 +15,31 @@
*/
package org.traccar.schedule;
-import org.traccar.Context;
+import org.traccar.session.ConnectionManager;
+import javax.inject.Inject;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
-public class TaskWebSocketKeepalive implements Runnable {
+public class TaskWebSocketKeepalive implements ScheduleTask {
private static final long PERIOD_SECONDS = 55;
+ private final ConnectionManager connectionManager;
+
+ @Inject
+ public TaskWebSocketKeepalive(ConnectionManager connectionManager) {
+ this.connectionManager = connectionManager;
+ }
+
+ @Override
public void schedule(ScheduledExecutorService executor) {
executor.scheduleAtFixedRate(this, PERIOD_SECONDS, PERIOD_SECONDS, TimeUnit.SECONDS);
}
@Override
public void run() {
- Context.getConnectionManager().sendKeepalive();
+ connectionManager.sendKeepalive();
}
}