aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/BaseProtocolDecoder.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-12-27 16:38:13 +0500
committerAbyss777 <abyss@fox5.ru>2017-12-27 16:38:13 +0500
commitd489eac12119ed62f899569db121364b20b1c9dc (patch)
treeaac938b2511bb9d45a7048236b93c6d740c457be /src/org/traccar/BaseProtocolDecoder.java
parentf128ed17780ad56dfd889d617f518cc0310a96a7 (diff)
downloadtrackermap-server-d489eac12119ed62f899569db121364b20b1c9dc.tar.gz
trackermap-server-d489eac12119ed62f899569db121364b20b1c9dc.tar.bz2
trackermap-server-d489eac12119ed62f899569db121364b20b1c9dc.zip
Implement device disable
Diffstat (limited to 'src/org/traccar/BaseProtocolDecoder.java')
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index 2d6286bf8..e412134d1 100644
--- a/src/org/traccar/BaseProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -85,12 +85,13 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
private Map<SocketAddress, DeviceSession> addressDeviceSessions = new HashMap<>(); // connectionless protocols
private long findDeviceId(SocketAddress remoteAddress, String... uniqueIds) {
- long deviceId = 0;
if (uniqueIds.length > 0) {
+ long deviceId = 0;
+ Device device = null;
try {
for (String uniqueId : uniqueIds) {
if (uniqueId != null) {
- Device device = Context.getIdentityManager().getByUniqueId(uniqueId);
+ device = Context.getIdentityManager().getByUniqueId(uniqueId);
if (device != null) {
deviceId = device.getId();
break;
@@ -100,22 +101,27 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
} catch (Exception e) {
Log.warning(e);
}
+ if (deviceId == 0 && Context.getConfig().getBoolean("database.registerUnknown")) {
+ return addUnknownDevice(uniqueIds[0]);
+ }
+ if (device != null && !device.getDisabled() || Context.getConfig().getBoolean("database.storeDisabled")) {
+ return deviceId;
+ }
+ StringBuilder message = new StringBuilder();
if (deviceId == 0) {
- if (Context.getConfig().getBoolean("database.registerUnknown")) {
- return addUnknownDevice(uniqueIds[0]);
- }
-
- StringBuilder message = new StringBuilder("Unknown device -");
- for (String uniqueId : uniqueIds) {
- message.append(" ").append(uniqueId);
- }
- if (remoteAddress != null) {
- message.append(" (").append(((InetSocketAddress) remoteAddress).getHostString()).append(")");
- }
- Log.warning(message.toString());
+ message.append("Unknown device -");
+ } else {
+ message.append("Disabled device -");
+ }
+ for (String uniqueId : uniqueIds) {
+ message.append(" ").append(uniqueId);
+ }
+ if (remoteAddress != null) {
+ message.append(" (").append(((InetSocketAddress) remoteAddress).getHostString()).append(")");
}
+ Log.warning(message.toString());
}
- return deviceId;
+ return 0;
}
public DeviceSession getDeviceSession(Channel channel, SocketAddress remoteAddress, String... uniqueIds) {