aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-10-23 09:50:35 +0500
committerAbyss777 <abyss@fox5.ru>2017-10-23 09:50:35 +0500
commit0283458de495e8f9f5393b1184c7a670e9851dcc (patch)
tree004593691cb92e1f0bb76f74a90b733f6bee6408 /src/org/traccar/database
parented72ff6e7f964bc56a4948c15c97f37c072bf326 (diff)
downloadtrackermap-server-0283458de495e8f9f5393b1184c7a670e9851dcc.tar.gz
trackermap-server-0283458de495e8f9f5393b1184c7a670e9851dcc.tar.bz2
trackermap-server-0283458de495e8f9f5393b1184c7a670e9851dcc.zip
Implement command cloning
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r--src/org/traccar/database/CommandsManager.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/org/traccar/database/CommandsManager.java b/src/org/traccar/database/CommandsManager.java
index 07695cbf7..9ceb995ef 100644
--- a/src/org/traccar/database/CommandsManager.java
+++ b/src/org/traccar/database/CommandsManager.java
@@ -48,13 +48,9 @@ public class CommandsManager extends ExtendedObjectManager<Command> {
public boolean sendCommand(Command command) throws Exception {
long deviceId = command.getDeviceId();
if (command.getId() != 0) {
- Command savedCommand = getById(command.getId());
- command.setTextChannel(savedCommand.getTextChannel());
- command.setType(savedCommand.getType());
- command.setAttributes(savedCommand.getAttributes());
- command.setDescription(savedCommand.getDescription());
+ command = getById(command.getId()).clone();
+ command.setDeviceId(deviceId);
}
- boolean sent = true;
if (command.getTextChannel()) {
Position lastPosition = Context.getIdentityManager().getLastPosition(deviceId);
String phone = Context.getIdentityManager().getById(deviceId).getPhone();
@@ -75,10 +71,11 @@ public class CommandsManager extends ExtendedObjectManager<Command> {
if (activeDevice != null) {
activeDevice.sendCommand(command);
} else {
- sent = !getDeviceQueue(deviceId).add(command);
+ getDeviceQueue(deviceId).add(command);
+ return false;
}
}
- return sent;
+ return true;
}
public Collection<Long> getSupportedCommands(long deviceId) {