aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/protocol')
-rw-r--r--src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java7
-rw-r--r--src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java17
2 files changed, 5 insertions, 19 deletions
diff --git a/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java b/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java
index 5b352a961..8b47701fd 100644
--- a/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/LeafSpyProtocolDecoder.java
@@ -122,13 +122,8 @@ public class LeafSpyProtocolDecoder extends BaseHttpProtocolDecoder {
}
if (position.getDeviceId() != 0) {
- if (channel != null) {
- HttpResponse response = new DefaultFullHttpResponse(
- HttpVersion.HTTP_1_1,
- HttpResponseStatus.OK,
+ sendResponse(channel, HttpResponseStatus.OK,
Unpooled.copiedBuffer("\"status\":\"0\"", StandardCharsets.US_ASCII));
- channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
- }
return position;
} else {
sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
diff --git a/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java
index 47aa86da7..26ce2fe53 100644
--- a/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/PiligrimProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 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.
@@ -18,15 +18,11 @@ package org.traccar.protocol;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
-import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.FullHttpRequest;
-import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpResponseStatus;
-import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.QueryStringDecoder;
-import org.traccar.BaseProtocolDecoder;
+import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
-import org.traccar.NetworkMessage;
import org.traccar.Protocol;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
@@ -37,19 +33,14 @@ import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
-public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
+public class PiligrimProtocolDecoder extends BaseHttpProtocolDecoder {
public PiligrimProtocolDecoder(Protocol protocol) {
super(protocol);
}
private void sendResponse(Channel channel, String message) {
- if (channel != null) {
- FullHttpResponse response = new DefaultFullHttpResponse(
- HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
- Unpooled.copiedBuffer(message, StandardCharsets.US_ASCII));
- channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
- }
+ sendResponse(channel, HttpResponseStatus.OK, Unpooled.copiedBuffer(message, StandardCharsets.US_ASCII));
}
public static final int MSG_GPS = 0xF1;