diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-29 10:48:34 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-06-29 10:48:34 +1200 |
commit | d1c4cd526845aad56c5b0a3e20454638bbc7fecc (patch) | |
tree | 565ee245ea0e98b88674b775147fbc6d3e1933cb /src/org/traccar/BaseProtocolDecoder.java | |
parent | 88b3f00f3855aa408c7859051efdcb5b37fe559f (diff) | |
download | trackermap-server-d1c4cd526845aad56c5b0a3e20454638bbc7fecc.tar.gz trackermap-server-d1c4cd526845aad56c5b0a3e20454638bbc7fecc.tar.bz2 trackermap-server-d1c4cd526845aad56c5b0a3e20454638bbc7fecc.zip |
Merge commands implmentation (fix #1271)
Diffstat (limited to 'src/org/traccar/BaseProtocolDecoder.java')
-rw-r--r-- | src/org/traccar/BaseProtocolDecoder.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java index b10f4d355..6e9efd830 100644 --- a/src/org/traccar/BaseProtocolDecoder.java +++ b/src/org/traccar/BaseProtocolDecoder.java @@ -16,7 +16,6 @@ package org.traccar; import java.net.SocketAddress; -import java.util.Properties; import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.ChannelEvent; @@ -25,7 +24,6 @@ import static org.jboss.netty.channel.Channels.fireMessageReceived; import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.handler.codec.oneone.OneToOneDecoder; -import org.traccar.database.DataManager; import org.traccar.helper.Log; import org.traccar.model.Device; @@ -34,10 +32,10 @@ import org.traccar.model.Device; */ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { - private final String protocol; + private final Protocol protocol; - public String getProtocol() { - return protocol; + public String getProtocolName() { + return protocol.getName(); } private long deviceId; @@ -50,11 +48,12 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { return deviceId; } - public boolean identify(String uniqueId, boolean logWarning) { + public boolean identify(String uniqueId, Channel channel, SocketAddress remoteAddress, boolean logWarning) { try { Device device = Context.getDataManager().getDeviceByUniqueId(uniqueId); if (device != null) { deviceId = device.getId(); + Context.getDataManager().setActiveDevice(device.getUniqueId(), protocol, channel, remoteAddress); return true; } else { deviceId = 0; @@ -70,11 +69,15 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder { } } - public boolean identify(String uniqueId) { - return identify(uniqueId, true); + public boolean identify(String uniqueId, Channel channel, SocketAddress remoteAddress) { + return identify(uniqueId, channel, remoteAddress, true); } - public BaseProtocolDecoder(String protocol) { + public boolean identify(String uniqueId, Channel channel) { + return identify(uniqueId, channel, null, true); + } + + public BaseProtocolDecoder(Protocol protocol) { this.protocol = protocol; } |