diff options
author | jcardus <joaquim.cardeira@gmail.com> | 2020-03-25 17:25:19 +0000 |
---|---|---|
committer | jcardus <joaquim.cardeira@gmail.com> | 2020-03-25 17:25:19 +0000 |
commit | feac85bad4004fb3e316a88285626e12840398d2 (patch) | |
tree | d268a79d63b9d1f27b6e433fedc90de7b427b172 /src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java | |
parent | 7b669e3181f637f06b31b55bd930584c7b08e897 (diff) | |
parent | f3d465abe7f255ec44e976caade642e4c2fd7598 (diff) | |
download | trackermap-server-feac85bad4004fb3e316a88285626e12840398d2.tar.gz trackermap-server-feac85bad4004fb3e316a88285626e12840398d2.tar.bz2 trackermap-server-feac85bad4004fb3e316a88285626e12840398d2.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java')
-rw-r--r-- | src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java index 3bc71de81..ec9bbc240 100644 --- a/src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/OsmAndProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2013 - 2020 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,15 +15,19 @@ */ package org.traccar.protocol; +import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import io.netty.handler.codec.http.FullHttpRequest; import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.QueryStringDecoder; import org.traccar.BaseHttpProtocolDecoder; +import org.traccar.Context; import org.traccar.DeviceSession; import org.traccar.Protocol; +import org.traccar.database.CommandsManager; import org.traccar.helper.DateUtil; import org.traccar.model.CellTower; +import org.traccar.model.Command; import org.traccar.model.Network; import org.traccar.model.Position; import org.traccar.model.WifiAccessPoint; @@ -173,7 +177,18 @@ public class OsmAndProtocolDecoder extends BaseHttpProtocolDecoder { } if (position.getDeviceId() != 0) { - sendResponse(channel, HttpResponseStatus.OK); + String response = null; + CommandsManager commandsManager = Context.getCommandsManager(); + if (commandsManager != null) { + for (Command command : commandsManager.readQueuedCommands(position.getDeviceId(), 1)) { + response = command.getString(Command.KEY_DATA); + } + } + if (response != null) { + sendResponse(channel, HttpResponseStatus.OK, Unpooled.copiedBuffer(response, StandardCharsets.UTF_8)); + } else { + sendResponse(channel, HttpResponseStatus.OK); + } return position; } else { sendResponse(channel, HttpResponseStatus.BAD_REQUEST); @@ -181,4 +196,8 @@ public class OsmAndProtocolDecoder extends BaseHttpProtocolDecoder { } } + @Override + protected void sendQueuedCommands(Channel channel, SocketAddress remoteAddress, long deviceId) { + } + } |