diff options
author | Abyss777 <abyss@fox5.ru> | 2017-10-19 10:03:02 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-10-19 10:03:02 +0500 |
commit | a2f215fe63bd313bfac2a894c170673ccbc252c4 (patch) | |
tree | 2fa849c58b91133a4c3335e72477561f45152d9d /src/org/traccar/api/resource | |
parent | 3f5a5e81fe08c7ae0b136d52b4840d5085e12f23 (diff) | |
download | trackermap-server-a2f215fe63bd313bfac2a894c170673ccbc252c4.tar.gz trackermap-server-a2f215fe63bd313bfac2a894c170673ccbc252c4.tar.bz2 trackermap-server-a2f215fe63bd313bfac2a894c170673ccbc252c4.zip |
Implement buffered commands
Diffstat (limited to 'src/org/traccar/api/resource')
-rw-r--r-- | src/org/traccar/api/resource/CommandResource.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/org/traccar/api/resource/CommandResource.java b/src/org/traccar/api/resource/CommandResource.java index 8da9f8447..996c15daf 100644 --- a/src/org/traccar/api/resource/CommandResource.java +++ b/src/org/traccar/api/resource/CommandResource.java @@ -62,15 +62,19 @@ public class CommandResource extends ExtendedObjectResource<Command> { Context.getPermissionsManager().checkReadonly(getUserId()); long deviceId = entity.getDeviceId(); long id = entity.getId(); + boolean sent; if (deviceId != 0 && id != 0) { Context.getPermissionsManager().checkPermission(Command.class, getUserId(), id); Context.getPermissionsManager().checkDevice(getUserId(), deviceId); Context.getPermissionsManager().checkUserDeviceCommand(getUserId(), deviceId, id); - Context.getCommandsManager().sendCommand(id, deviceId); + sent = Context.getCommandsManager().sendCommand(id, deviceId); } else { Context.getPermissionsManager().checkLimitCommands(getUserId()); Context.getPermissionsManager().checkDevice(getUserId(), deviceId); - Context.getCommandsManager().sendCommand(entity); + sent = Context.getCommandsManager().sendCommand(entity, deviceId); + } + if (!sent) { + return Response.accepted(entity).build(); } return Response.ok(entity).build(); } |