aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r--src/main/java/org/traccar/database/CommandsManager.java14
-rw-r--r--src/main/java/org/traccar/database/ConnectionManager.java4
2 files changed, 10 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/database/CommandsManager.java b/src/main/java/org/traccar/database/CommandsManager.java
index de6eeeba8..99114db5e 100644
--- a/src/main/java/org/traccar/database/CommandsManager.java
+++ b/src/main/java/org/traccar/database/CommandsManager.java
@@ -161,21 +161,27 @@ public class CommandsManager extends ExtendedObjectManager<Command> {
}
}
- public void sendQueuedCommands(ActiveDevice activeDevice) {
+ public Collection<Command> readQueuedCommands(long deviceId) {
+ return readQueuedCommands(deviceId, Integer.MAX_VALUE);
+ }
+
+ public Collection<Command> readQueuedCommands(long deviceId, int count) {
Queue<Command> deviceQueue;
try {
readLock();
- deviceQueue = deviceQueues.get(activeDevice.getDeviceId());
+ deviceQueue = deviceQueues.get(deviceId);
} finally {
readUnlock();
}
+ Collection<Command> result = new ArrayList<>();
if (deviceQueue != null) {
Command command = deviceQueue.poll();
- while (command != null) {
- activeDevice.sendCommand(command);
+ while (command != null && result.size() < count) {
+ result.add(command);
command = deviceQueue.poll();
}
}
+ return result;
}
}
diff --git a/src/main/java/org/traccar/database/ConnectionManager.java b/src/main/java/org/traccar/database/ConnectionManager.java
index dd0071143..4d43bc71b 100644
--- a/src/main/java/org/traccar/database/ConnectionManager.java
+++ b/src/main/java/org/traccar/database/ConnectionManager.java
@@ -139,10 +139,6 @@ public class ConnectionManager {
}
updateDevice(device);
-
- if (status.equals(Device.STATUS_ONLINE) && !oldStatus.equals(Device.STATUS_ONLINE)) {
- Context.getCommandsManager().sendQueuedCommands(getActiveDevice(deviceId));
- }
}
public Map<Event, Position> updateDeviceState(long deviceId) {