diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2012-12-04 21:24:41 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2012-12-04 21:24:41 +1300 |
commit | 8d49ced822a1ae5c8b3f065178116e95a4f55c85 (patch) | |
tree | c5ab665fa17511ce808e34d2544ac6e1eb252061 /src/org/traccar/TrackerEventHandler.java | |
parent | 2b6d8cb12c6a307b4ee9a0af12101042ec78803c (diff) | |
download | trackermap-server-8d49ced822a1ae5c8b3f065178116e95a4f55c85.tar.gz trackermap-server-8d49ced822a1ae5c8b3f065178116e95a4f55c85.tar.bz2 trackermap-server-8d49ced822a1ae5c8b3f065178116e95a4f55c85.zip |
Added Navis protocol (fix #99)
Diffstat (limited to 'src/org/traccar/TrackerEventHandler.java')
-rw-r--r-- | src/org/traccar/TrackerEventHandler.java | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/org/traccar/TrackerEventHandler.java b/src/org/traccar/TrackerEventHandler.java index 6483e52e7..11cf41fad 100644 --- a/src/org/traccar/TrackerEventHandler.java +++ b/src/org/traccar/TrackerEventHandler.java @@ -15,6 +15,7 @@ */ package org.traccar; +import java.util.List; import org.jboss.netty.channel.*; import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler; import org.jboss.netty.handler.timeout.IdleStateEvent; @@ -37,36 +38,41 @@ public class TrackerEventHandler extends IdleStateAwareChannelHandler { super(); dataManager = newDataManager; } + + private void processSinglePosition(Position position) { + if (position == null) { + Log.info("null message"); + } else { + Log.info( + "id: " + position.getId() + + ", deviceId: " + position.getDeviceId() + + ", valid: " + position.getValid() + + ", time: " + position.getTime() + + ", latitude: " + position.getLatitude() + + ", longitude: " + position.getLongitude() + + ", altitude: " + position.getAltitude() + + ", speed: " + position.getSpeed() + + ", course: " + position.getCourse() + + ", power: " + position.getPower()); + } + + // Write position to database + try { + dataManager.addPosition(position); + } catch (Exception error) { + Log.info("Exception during query execution"); + Log.warning(error.getMessage()); + } + } @Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) { - if (e.getMessage() instanceof Position) { - - Position position = (Position) e.getMessage(); - - if (position == null) { - Log.info("null message"); - } else { - Log.info( - "id: " + position.getId() + - ", deviceId: " + position.getDeviceId() + - ", valid: " + position.getValid() + - ", time: " + position.getTime() + - ", latitude: " + position.getLatitude() + - ", longitude: " + position.getLongitude() + - ", altitude: " + position.getAltitude() + - ", speed: " + position.getSpeed() + - ", course: " + position.getCourse() + - ", power: " + position.getPower()); - } - - // Write position to database - try { - dataManager.addPosition(position); - } catch (Exception error) { - Log.info("Exception during query execution"); - Log.warning(error.getMessage()); + processSinglePosition((Position) e.getMessage()); + } else if (e.getMessage() instanceof List) { + List<Position> positions = (List<Position>) e.getMessage(); + for (Position position : positions) { + processSinglePosition(position); } } } |