aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-30 18:39:50 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-30 18:39:50 -0700
commit4dc602d8a7700924b0117424533046b28f4a8df4 (patch)
treed1f5f1edcd8db36716d3d1f44cd57d69d0e6d996 /src/main/java/org/traccar/database
parent9a68d1045f30bf8397d6cbf90df8f42f40979591 (diff)
downloadtrackermap-server-4dc602d8a7700924b0117424533046b28f4a8df4.tar.gz
trackermap-server-4dc602d8a7700924b0117424533046b28f4a8df4.tar.bz2
trackermap-server-4dc602d8a7700924b0117424533046b28f4a8df4.zip
Combine active device and session
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r--src/main/java/org/traccar/database/CommandsManager.java12
-rw-r--r--src/main/java/org/traccar/database/DeviceManager.java6
-rw-r--r--src/main/java/org/traccar/database/IdentityManager.java2
3 files changed, 10 insertions, 10 deletions
diff --git a/src/main/java/org/traccar/database/CommandsManager.java b/src/main/java/org/traccar/database/CommandsManager.java
index 3adf5d2e9..57ce0f9a4 100644
--- a/src/main/java/org/traccar/database/CommandsManager.java
+++ b/src/main/java/org/traccar/database/CommandsManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2022 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -34,7 +34,7 @@ import org.traccar.Context;
import org.traccar.model.Command;
import org.traccar.model.Typed;
import org.traccar.model.Position;
-import org.traccar.session.ActiveDevice;
+import org.traccar.session.DeviceSession;
public class CommandsManager extends ExtendedObjectManager<Command> {
@@ -75,10 +75,10 @@ public class CommandsManager extends ExtendedObjectManager<Command> {
throw new RuntimeException("Command " + command.getType() + " is not supported");
}
} else {
- ActiveDevice activeDevice = Context.getConnectionManager().getActiveDevice(deviceId);
- if (activeDevice != null) {
- if (activeDevice.supportsLiveCommands()) {
- activeDevice.sendCommand(command);
+ DeviceSession deviceSession = Context.getConnectionManager().getDeviceSession(deviceId);
+ if (deviceSession != null) {
+ if (deviceSession.supportsLiveCommands()) {
+ deviceSession.sendCommand(command);
} else {
getDeviceQueue(deviceId).add(command);
return false;
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java
index 0e5056e57..b1ea0b8b7 100644
--- a/src/main/java/org/traccar/database/DeviceManager.java
+++ b/src/main/java/org/traccar/database/DeviceManager.java
@@ -68,7 +68,7 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
}
@Override
- public long addUnknownDevice(String uniqueId) {
+ public Device addUnknownDevice(String uniqueId) {
Device device = new Device();
device.setName(uniqueId);
device.setUniqueId(uniqueId);
@@ -89,10 +89,10 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
Context.getPermissionsManager().refreshAllExtendedPermissions();
}
- return device.getId();
+ return device;
} catch (StorageException e) {
LOGGER.warn("Automatic device registration error", e);
- return 0;
+ return null;
}
}
diff --git a/src/main/java/org/traccar/database/IdentityManager.java b/src/main/java/org/traccar/database/IdentityManager.java
index af6a6ce71..ee386fdfd 100644
--- a/src/main/java/org/traccar/database/IdentityManager.java
+++ b/src/main/java/org/traccar/database/IdentityManager.java
@@ -20,7 +20,7 @@ import org.traccar.model.Position;
public interface IdentityManager {
- long addUnknownDevice(String uniqueId);
+ Device addUnknownDevice(String uniqueId);
Device getById(long id);