aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-11-17 20:19:23 -0800
committerAnton Tananaev <anton@traccar.org>2023-11-17 20:19:23 -0800
commite5827b74db9432392b702f676fedb2aaacfd69f0 (patch)
treeee404ce0ebf354e1b8df68b0921ee81192a4a95d /src
parenteacc6603272ba06ea257807415a966474e8cd020 (diff)
downloadtrackermap-server-e5827b74db9432392b702f676fedb2aaacfd69f0.tar.gz
trackermap-server-e5827b74db9432392b702f676fedb2aaacfd69f0.tar.bz2
trackermap-server-e5827b74db9432392b702f676fedb2aaacfd69f0.zip
Fix TAIP ACK message
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/protocol/TaipPrefixEncoder.java24
-rw-r--r--src/main/java/org/traccar/protocol/TaipProtocol.java11
2 files changed, 10 insertions, 25 deletions
diff --git a/src/main/java/org/traccar/protocol/TaipPrefixEncoder.java b/src/main/java/org/traccar/protocol/TaipPrefixEncoder.java
index 48419af2a..75fd447d0 100644
--- a/src/main/java/org/traccar/protocol/TaipPrefixEncoder.java
+++ b/src/main/java/org/traccar/protocol/TaipPrefixEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2021 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2021 - 2023 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,40 +15,20 @@
*/
package org.traccar.protocol;
-import com.google.inject.Inject;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
-import org.traccar.Protocol;
-import org.traccar.config.Config;
-import org.traccar.config.Keys;
import java.util.List;
@ChannelHandler.Sharable
public class TaipPrefixEncoder extends MessageToMessageEncoder<ByteBuf> {
- private final Protocol protocol;
- private Config config;
-
- public TaipPrefixEncoder(Protocol protocol) {
- this.protocol = protocol;
- }
-
- @Inject
- public void setConfig(Config config) {
- this.config = config;
- }
-
@Override
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) {
- if (config.getBoolean(Keys.PROTOCOL_PREFIX.withPrefix(protocol.getName()))) {
- out.add(Unpooled.wrappedBuffer(Unpooled.wrappedBuffer(new byte[] {0x20, 0x20, 0x06, 0x00}), msg.retain()));
- } else {
- out.add(msg.retain());
- }
+ out.add(Unpooled.wrappedBuffer(Unpooled.wrappedBuffer(new byte[] {0x20, 0x20, 0x06, 0x00}), msg.retain()));
}
}
diff --git a/src/main/java/org/traccar/protocol/TaipProtocol.java b/src/main/java/org/traccar/protocol/TaipProtocol.java
index 71ab485ca..f57bb296c 100644
--- a/src/main/java/org/traccar/protocol/TaipProtocol.java
+++ b/src/main/java/org/traccar/protocol/TaipProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2023 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.
@@ -24,6 +24,7 @@ import org.traccar.TrackerServer;
import org.traccar.config.Config;
import jakarta.inject.Inject;
+import org.traccar.config.Keys;
public class TaipProtocol extends BaseProtocol {
@@ -33,7 +34,9 @@ public class TaipProtocol extends BaseProtocol {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline, Config config) {
pipeline.addLast(new CharacterDelimiterFrameDecoder(1024, '<'));
- pipeline.addLast(new TaipPrefixEncoder(TaipProtocol.this));
+ if (config.getBoolean(Keys.PROTOCOL_PREFIX.withPrefix(getName()))) {
+ pipeline.addLast(new TaipPrefixEncoder());
+ }
pipeline.addLast(new StringDecoder());
pipeline.addLast(new StringEncoder());
pipeline.addLast(new TaipProtocolDecoder(TaipProtocol.this));
@@ -42,7 +45,9 @@ public class TaipProtocol extends BaseProtocol {
addServer(new TrackerServer(config, getName(), true) {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline, Config config) {
- pipeline.addLast(new TaipPrefixEncoder(TaipProtocol.this));
+ if (config.getBoolean(Keys.PROTOCOL_PREFIX.withPrefix(getName()))) {
+ pipeline.addLast(new TaipPrefixEncoder());
+ }
pipeline.addLast(new StringDecoder());
pipeline.addLast(new StringEncoder());
pipeline.addLast(new TaipProtocolDecoder(TaipProtocol.this));