diff options
author | anton2920 <anton2920@gmail.com> | 2022-09-06 10:53:38 +0100 |
---|---|---|
committer | anton2920 <anton2920@gmail.com> | 2022-09-07 09:48:53 +0100 |
commit | b3caf3c1cee6cb665e8ac05be35d9258c353771e (patch) | |
tree | 5aa092fc937f5a3e8b54f215f530fec613656d71 | |
parent | 26e3d616ef17db2c30da0e9c8c0a7a1e9182cc6c (diff) | |
download | trackermap-server-b3caf3c1cee6cb665e8ac05be35d9258c353771e.tar.gz trackermap-server-b3caf3c1cee6cb665e8ac05be35d9258c353771e.tar.bz2 trackermap-server-b3caf3c1cee6cb665e8ac05be35d9258c353771e.zip |
Replaced hard-coded ID with phone number
-rw-r--r-- | src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java index d1f667f6f..da8991bd3 100644 --- a/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java +++ b/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java @@ -157,11 +157,6 @@ public class PiligrimProtocolDecoder extends BaseHttpProtocolDecoder { } else if (uri.startsWith("/push.do")) { sendResponse(channel, "PUSH.DO: OK"); - DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, "123456"); - if (deviceSession == null) { - return null; - } - /* Getting payload */ ByteBuf content_stream = request.content(); byte[] payload_bytes = new byte[Integer.parseInt(request.headers().get("Content-Length"))]; @@ -173,7 +168,15 @@ public class PiligrimProtocolDecoder extends BaseHttpProtocolDecoder { */ String[] payload_parts = payload.split("&"); /* System.out.println("Payload parts: " + Arrays.toString(payload_parts)); */ - /* String phone_number = payload_parts[1].substring(15); */ + String phone_number = payload_parts[1].substring(15); + DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, phone_number); + if (deviceSession == null) { + return null; + } + + /* TODO: generalize this process; + * TODO: use keys for flags in 'positions'. + */ String message = payload_parts[2].substring(8).replaceFirst("ALARM KEY; ", ""); /* System.out.println("Phone number: " + phone_number); */ /* System.out.println("Message: " + message); */ |