aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/BaseProtocol.java12
-rw-r--r--src/org/traccar/database/DataManager.java6
-rw-r--r--src/org/traccar/database/GeofenceManager.java17
-rw-r--r--src/org/traccar/database/NotificationManager.java2
-rw-r--r--src/org/traccar/events/GeofenceEventHandler.java4
-rw-r--r--src/org/traccar/geocode/GeocodeFarmReverseGeocoder.java6
-rw-r--r--src/org/traccar/helper/Checksum.java38
-rw-r--r--src/org/traccar/protocol/GatorProtocolDecoder.java1
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/HuaShengFrameDecoder.java1
-rw-r--r--src/org/traccar/protocol/HuaShengProtocol.java1
-rw-r--r--src/org/traccar/protocol/HuaShengProtocolDecoder.java15
-rw-r--r--src/org/traccar/protocol/SuntechProtocol.java2
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocol.java5
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolEncoder.java62
16 files changed, 142 insertions, 40 deletions
diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java
index f968e81cc..352895629 100644
--- a/src/org/traccar/BaseProtocol.java
+++ b/src/org/traccar/BaseProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ * Copyright 2015 - 2016 Anton Tananaev (anton.tananaev@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,9 @@ public abstract class BaseProtocol implements Protocol {
@Override
public void sendCommand(ActiveDevice activeDevice, Command command) {
- if (command.getType().equals(Command.TYPE_CUSTOM)) {
+ if (supportedCommands.contains(command.getType())) {
+ activeDevice.write(command);
+ } else if (command.getType().equals(Command.TYPE_CUSTOM)) {
String data = (String) command.getAttributes().get(Command.KEY_DATA);
if (activeDevice.getChannel().getPipeline().get(StringEncoder.class) != null) {
activeDevice.write(data);
@@ -60,11 +62,7 @@ public abstract class BaseProtocol implements Protocol {
activeDevice.write(ChannelBuffers.wrappedBuffer(DatatypeConverter.parseHexBinary(data)));
}
} else {
- if (!supportedCommands.contains(command.getType())) {
- throw new RuntimeException("Command "
- + command.getType() + " is not supported in protocol " + getName());
- }
- activeDevice.write(command);
+ throw new RuntimeException("Command " + command.getType() + " is not supported in protocol " + getName());
}
}
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java
index 031703023..2d3b75db7 100644
--- a/src/org/traccar/database/DataManager.java
+++ b/src/org/traccar/database/DataManager.java
@@ -241,7 +241,7 @@ public class DataManager implements IdentityManager {
}
public Group getGroupById(long id) {
- boolean forceUpdate;
+ /*boolean forceUpdate;
groupsLock.readLock().lock();
try {
forceUpdate = !groupsById.containsKey(id);
@@ -253,7 +253,7 @@ public class DataManager implements IdentityManager {
updateGroupCache(forceUpdate);
} catch (SQLException e) {
Log.warning(e);
- }
+ }*/
groupsLock.readLock().lock();
try {
@@ -356,7 +356,7 @@ public class DataManager implements IdentityManager {
boolean forceUpdate;
devicesLock.readLock().lock();
try {
- forceUpdate = devicesById.values().isEmpty();
+ forceUpdate = devicesById.isEmpty();
} finally {
devicesLock.readLock().unlock();
}
diff --git a/src/org/traccar/database/GeofenceManager.java b/src/org/traccar/database/GeofenceManager.java
index cc9f82879..d3cf2ad1f 100644
--- a/src/org/traccar/database/GeofenceManager.java
+++ b/src/org/traccar/database/GeofenceManager.java
@@ -30,11 +30,12 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.traccar.Context;
import org.traccar.helper.Log;
import org.traccar.model.Device;
+import org.traccar.model.DeviceGeofence;
import org.traccar.model.Geofence;
+import org.traccar.model.GeofencePermission;
+import org.traccar.model.Group;
import org.traccar.model.GroupGeofence;
import org.traccar.model.Position;
-import org.traccar.model.DeviceGeofence;
-import org.traccar.model.GeofencePermission;
public class GeofenceManager {
@@ -137,15 +138,15 @@ public class GeofenceManager {
}
for (Device device : dataManager.getAllDevicesCached()) {
- long groupId = device.getGroupId();
- while (groupId != 0) {
+ Group group = dataManager.getGroupById(device.getGroupId());
+ while (group != null) {
getDeviceGeofences(deviceGeofencesWithGroups,
- device.getId()).addAll(getGroupGeofences(groupId));
- groupId = dataManager.getGroupById(groupId).getGroupId();
+ device.getId()).addAll(getGroupGeofences(group.getGroupId()));
+ group = dataManager.getGroupById(group.getGroupId());
}
List<Long> deviceGeofenceIds = device.getGeofenceIds();
if (deviceGeofenceIds == null) {
- deviceGeofenceIds = new ArrayList<Long>();
+ deviceGeofenceIds = new ArrayList<>();
} else {
deviceGeofenceIds.clear();
}
@@ -232,7 +233,7 @@ public class GeofenceManager {
}
public List<Long> getCurrentDeviceGeofences(Position position) {
- List<Long> result = new ArrayList<Long>();
+ List<Long> result = new ArrayList<>();
for (Long geofenceId : getAllDeviceGeofences(position.getDeviceId())) {
if (getGeofence(geofenceId).getGeometry().containsPoint(position.getLatitude(), position.getLongitude())) {
result.add(geofenceId);
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java
index ae91d81cc..d263e160f 100644
--- a/src/org/traccar/database/NotificationManager.java
+++ b/src/org/traccar/database/NotificationManager.java
@@ -87,7 +87,7 @@ public class NotificationManager {
public Set<Notification> getUserNotifications(long userId) {
notificationsLock.readLock().lock();
try {
- return getUserNotificationsUnsafe(userId);
+ return getUserNotificationsUnsafe(userId);
} finally {
notificationsLock.readLock().unlock();
}
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java
index e9a4a640f..a3d8aa375 100644
--- a/src/org/traccar/events/GeofenceEventHandler.java
+++ b/src/org/traccar/events/GeofenceEventHandler.java
@@ -52,11 +52,11 @@ public class GeofenceEventHandler extends BaseEventHandler {
}
List<Long> currentGeofences = geofenceManager.getCurrentDeviceGeofences(position);
- List<Long> oldGeofences = new ArrayList<Long>();
+ List<Long> oldGeofences = new ArrayList<>();
if (device.getGeofenceIds() != null) {
oldGeofences.addAll(device.getGeofenceIds());
}
- List<Long> newGeofences = new ArrayList<Long>(currentGeofences);
+ List<Long> newGeofences = new ArrayList<>(currentGeofences);
newGeofences.removeAll(oldGeofences);
oldGeofences.removeAll(currentGeofences);
diff --git a/src/org/traccar/geocode/GeocodeFarmReverseGeocoder.java b/src/org/traccar/geocode/GeocodeFarmReverseGeocoder.java
index e100d3081..306fc25b8 100644
--- a/src/org/traccar/geocode/GeocodeFarmReverseGeocoder.java
+++ b/src/org/traccar/geocode/GeocodeFarmReverseGeocoder.java
@@ -19,12 +19,14 @@ import javax.json.JsonObject;
public class GeocodeFarmReverseGeocoder extends JsonReverseGeocoder {
+ private static final String URL = "https://www.geocode.farm/v3/json/reverse/";
+
public GeocodeFarmReverseGeocoder(int cacheSize) {
- super("https://www.geocode.farm/v3/json/reverse/?lat=%f&lon=%f&country=us&lang=en&count=1", cacheSize);
+ super(URL + "?lat=%f&lon=%f&country=us&lang=en&count=1", cacheSize);
}
public GeocodeFarmReverseGeocoder(String key, int cacheSize) {
- super("https://www.geocode.farm/v3/json/reverse/?lat=%f&lon=%f&country=us&lang=en&count=1&key=" + key, cacheSize);
+ super(URL + "?lat=%f&lon=%f&country=us&lang=en&count=1&key=" + key, cacheSize);
}
@Override
diff --git a/src/org/traccar/helper/Checksum.java b/src/org/traccar/helper/Checksum.java
index 6a0a35b16..2a4b1191d 100644
--- a/src/org/traccar/helper/Checksum.java
+++ b/src/org/traccar/helper/Checksum.java
@@ -94,7 +94,43 @@ public final class Checksum {
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
};
+ private static final int[] CRC16_IBM_TABLE = {
+ 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
+ 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
+ 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
+ 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841,
+ 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40,
+ 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
+ 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641,
+ 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040,
+ 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
+ 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441,
+ 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41,
+ 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
+ 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41,
+ 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40,
+ 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
+ 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041,
+ 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240,
+ 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
+ 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41,
+ 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840,
+ 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
+ 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40,
+ 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640,
+ 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
+ 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241,
+ 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440,
+ 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
+ 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841,
+ 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40,
+ 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
+ 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641,
+ 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040,
+ };
+
// More info: http://reveng.sourceforge.net/crc-catalogue/16.htm
+ public static final String CRC16_IBM = "IBM";
public static final String CRC16_X25 = "X-25";
public static final String CRC16_CCITT_FALSE = "CCITT-FALSE";
public static final String CRC16_KERMIT = "KERMIT";
@@ -121,6 +157,8 @@ public final class Checksum {
public static int crc16(String type, ByteBuffer buf) {
switch (type) {
+ case CRC16_IBM:
+ return crc16Reflected(buf, 0, CRC16_IBM_TABLE);
case CRC16_X25:
return crc16Reflected(buf, 0xFFFF, CRC16_CCITT_TABLE_REVERSE) ^ 0xFFFF;
case CRC16_CCITT_FALSE:
diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java
index 94ca1fc3c..ade27a56a 100644
--- a/src/org/traccar/protocol/GatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/GatorProtocolDecoder.java
@@ -20,7 +20,6 @@ import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.helper.BcdUtil;
-import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 12c9d20b5..ce915fde8 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -271,9 +271,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (header == 0x7979) {
- int length = buf.readUnsignedShort();
- int dataLength = length - 6;
-
+ buf.readUnsignedShort(); // length
int type = buf.readUnsignedByte();
if (type == MSG_INFO) {
diff --git a/src/org/traccar/protocol/HuaShengFrameDecoder.java b/src/org/traccar/protocol/HuaShengFrameDecoder.java
index 922bc3979..5d68fef9e 100644
--- a/src/org/traccar/protocol/HuaShengFrameDecoder.java
+++ b/src/org/traccar/protocol/HuaShengFrameDecoder.java
@@ -16,7 +16,6 @@
package org.traccar.protocol;
import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
diff --git a/src/org/traccar/protocol/HuaShengProtocol.java b/src/org/traccar/protocol/HuaShengProtocol.java
index 351f886db..53a77c603 100644
--- a/src/org/traccar/protocol/HuaShengProtocol.java
+++ b/src/org/traccar/protocol/HuaShengProtocol.java
@@ -17,7 +17,6 @@ package org.traccar.protocol;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
import org.traccar.TrackerServer;
diff --git a/src/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
index 6743db47d..50517045b 100644
--- a/src/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -19,7 +19,8 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
-import org.traccar.helper.*;
+import org.traccar.helper.DateBuilder;
+import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -96,12 +97,12 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
String time = buf.readBytes(12).toString(StandardCharsets.US_ASCII);
DateBuilder dateBuilder = new DateBuilder()
- .setYear(Integer.valueOf(time.substring(0, 2)))
- .setMonth(Integer.valueOf(time.substring(2, 4)))
- .setDay(Integer.valueOf(time.substring(4, 6)))
- .setHour(Integer.valueOf(time.substring(6, 8)))
- .setMinute(Integer.valueOf(time.substring(8, 10)))
- .setSecond(Integer.valueOf(time.substring(10, 12)));
+ .setYear(Integer.parseInt(time.substring(0, 2)))
+ .setMonth(Integer.parseInt(time.substring(2, 4)))
+ .setDay(Integer.parseInt(time.substring(4, 6)))
+ .setHour(Integer.parseInt(time.substring(6, 8)))
+ .setMinute(Integer.parseInt(time.substring(8, 10)))
+ .setSecond(Integer.parseInt(time.substring(10, 12)));
position.setTime(dateBuilder.getDate());
position.setLongitude(buf.readInt() * 0.00001);
diff --git a/src/org/traccar/protocol/SuntechProtocol.java b/src/org/traccar/protocol/SuntechProtocol.java
index e06ed2aac..ce0e73280 100644
--- a/src/org/traccar/protocol/SuntechProtocol.java
+++ b/src/org/traccar/protocol/SuntechProtocol.java
@@ -32,7 +32,7 @@ public class SuntechProtocol extends BaseProtocol {
super("suntech");
setSupportedCommands(
Command.TYPE_ENGINE_STOP,
- Command.TYPE_ENGINE_STOP);
+ Command.TYPE_ENGINE_RESUME);
}
@Override
diff --git a/src/org/traccar/protocol/TeltonikaProtocol.java b/src/org/traccar/protocol/TeltonikaProtocol.java
index f944c3003..5a550d4c0 100644
--- a/src/org/traccar/protocol/TeltonikaProtocol.java
+++ b/src/org/traccar/protocol/TeltonikaProtocol.java
@@ -20,6 +20,7 @@ import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
import org.traccar.TrackerServer;
+import org.traccar.model.Command;
import java.util.List;
@@ -27,6 +28,8 @@ public class TeltonikaProtocol extends BaseProtocol {
public TeltonikaProtocol() {
super("teltonika");
+ setSupportedCommands(
+ Command.TYPE_CUSTOM);
}
@Override
@@ -35,12 +38,14 @@ public class TeltonikaProtocol extends BaseProtocol {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
pipeline.addLast("frameDecoder", new TeltonikaFrameDecoder());
+ pipeline.addLast("objectEncoder", new TeltonikaProtocolEncoder());
pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this));
}
});
serverList.add(new TrackerServer(new ConnectionlessBootstrap(), this.getName()) {
@Override
protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ pipeline.addLast("objectEncoder", new TeltonikaProtocolEncoder());
pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 1706a34a5..eb77cf350 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -52,9 +52,9 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private static final int CODEC_GH3000 = 0x07;
- private static final int CODEC_FM4X00 = 0x08;
- private static final int CODEC_12 = 0x0C;
+ public static final int CODEC_GH3000 = 0x07;
+ public static final int CODEC_FM4X00 = 0x08;
+ public static final int CODEC_12 = 0x0C;
private void decodeSerial(Position position, ChannelBuffer buf) {
diff --git a/src/org/traccar/protocol/TeltonikaProtocolEncoder.java b/src/org/traccar/protocol/TeltonikaProtocolEncoder.java
new file mode 100644
index 000000000..d91f7f7bf
--- /dev/null
+++ b/src/org/traccar/protocol/TeltonikaProtocolEncoder.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2016 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar.protocol;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.traccar.BaseProtocolEncoder;
+import org.traccar.helper.Checksum;
+import org.traccar.helper.Log;
+import org.traccar.model.Command;
+
+import java.nio.charset.StandardCharsets;
+
+public class TeltonikaProtocolEncoder extends BaseProtocolEncoder {
+
+ private ChannelBuffer encodeContent(String content) {
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+
+ buf.writeInt(0);
+ buf.writeInt(content.length() + 10);
+ buf.writeByte(TeltonikaProtocolDecoder.CODEC_12);
+ buf.writeByte(1); // quantity
+ buf.writeByte(5); // type
+ buf.writeInt(content.length() + 2);
+ buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII));
+ buf.writeByte('\r');
+ buf.writeByte('\n');
+ buf.writeByte(1); // quantity
+ buf.writeInt(Checksum.crc16(Checksum.CRC16_IBM, buf.toByteBuffer(8, buf.writerIndex() - 8)));
+
+ return buf;
+ }
+
+ @Override
+ protected Object encodeCommand(Command command) {
+
+ switch (command.getType()) {
+ case Command.TYPE_CUSTOM:
+ return encodeContent((String) command.getAttributes().get(Command.KEY_DATA));
+ default:
+ Log.warning(new UnsupportedOperationException(command.getType()));
+ break;
+ }
+
+ return null;
+ }
+
+}