aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/protocol/WondexProtocolDecoder.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-05-23 09:41:27 +0500
committerAbyss777 <abyss@fox5.ru>2016-05-23 09:41:27 +0500
commit0065906b1c745eb4305469e562b9c740e694074c (patch)
tree349c0cc279600964f7809068738ea70f34bb5216 /src/org/traccar/protocol/WondexProtocolDecoder.java
parentf8808f942a094efb723c66b83eeed8a88a8e01c6 (diff)
downloadtrackermap-server-0065906b1c745eb4305469e562b9c740e694074c.tar.gz
trackermap-server-0065906b1c745eb4305469e562b9c740e694074c.tar.bz2
trackermap-server-0065906b1c745eb4305469e562b9c740e694074c.zip
Two optimizations
Diffstat (limited to 'src/org/traccar/protocol/WondexProtocolDecoder.java')
-rw-r--r--src/org/traccar/protocol/WondexProtocolDecoder.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java
index 837f40a08..366466143 100644
--- a/src/org/traccar/protocol/WondexProtocolDecoder.java
+++ b/src/org/traccar/protocol/WondexProtocolDecoder.java
@@ -61,26 +61,28 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- if (((ChannelBuffer) msg).getUnsignedByte(0) == 0xD0) {
+ ChannelBuffer buf = (ChannelBuffer) msg;
- long deviceId = ((Long.reverseBytes((((ChannelBuffer) msg).getLong(0)))) >> 32) & 0xFFFFFFFFL;
+ if (buf.getUnsignedByte(0) == 0xD0) {
+
+ long deviceId = ((Long.reverseBytes(buf.getLong(0))) >> 32) & 0xFFFFFFFFL;
identify(String.valueOf(deviceId), channel, remoteAddress);
return null;
- } else if (((ChannelBuffer) msg).toString(StandardCharsets.US_ASCII).startsWith("$OK:")
- || ((ChannelBuffer) msg).toString(StandardCharsets.US_ASCII).startsWith("$ERR:")) {
+ } else if (buf.toString(StandardCharsets.US_ASCII).startsWith("$OK:")
+ || buf.toString(StandardCharsets.US_ASCII).startsWith("$ERR:")) {
Position position = new Position();
position.setProtocol(getProtocolName());
position.setDeviceId(getDeviceId());
getLastLocation(position, new Date());
position.setValid(false);
- position.set(Event.KEY_RESULT, ((ChannelBuffer) msg).toString(StandardCharsets.US_ASCII));
+ position.set(Event.KEY_RESULT, buf.toString(StandardCharsets.US_ASCII));
return position;
} else {
- Parser parser = new Parser(PATTERN, ((ChannelBuffer) msg).toString(StandardCharsets.US_ASCII));
+ Parser parser = new Parser(PATTERN, buf.toString(StandardCharsets.US_ASCII));
if (!parser.matches()) {
return null;
}