aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/GeolocationHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2018-06-02 22:12:44 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2018-06-02 22:12:44 +1200
commit06e3bd8b16da12baafc9a97ba5949b3f7ffb5e07 (patch)
tree8f5d7b71ca3fa39448e93b3d0652a7fa8d496932 /src/org/traccar/GeolocationHandler.java
parent5a9811c3771d92832c9bba718b5ec935844978e8 (diff)
downloadtrackermap-server-06e3bd8b16da12baafc9a97ba5949b3f7ffb5e07.tar.gz
trackermap-server-06e3bd8b16da12baafc9a97ba5949b3f7ffb5e07.tar.bz2
trackermap-server-06e3bd8b16da12baafc9a97ba5949b3f7ffb5e07.zip
Start Netty 4 migration
Diffstat (limited to 'src/org/traccar/GeolocationHandler.java')
-rw-r--r--src/org/traccar/GeolocationHandler.java30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/org/traccar/GeolocationHandler.java b/src/org/traccar/GeolocationHandler.java
index 346ad5904..0c204dc0b 100644
--- a/src/org/traccar/GeolocationHandler.java
+++ b/src/org/traccar/GeolocationHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 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,16 +15,15 @@
*/
package org.traccar;
-import org.jboss.netty.channel.ChannelEvent;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelUpstreamHandler;
-import org.jboss.netty.channel.Channels;
-import org.jboss.netty.channel.MessageEvent;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
import org.traccar.helper.Log;
import org.traccar.geolocation.GeolocationProvider;
import org.traccar.model.Position;
-public class GeolocationHandler implements ChannelUpstreamHandler {
+@ChannelHandler.Sharable
+public class GeolocationHandler extends ChannelInboundHandlerAdapter {
private final GeolocationProvider geolocationProvider;
private final boolean processInvalidPositions;
@@ -35,14 +34,7 @@ public class GeolocationHandler implements ChannelUpstreamHandler {
}
@Override
- public void handleUpstream(final ChannelHandlerContext ctx, ChannelEvent evt) throws Exception {
- if (!(evt instanceof MessageEvent)) {
- ctx.sendUpstream(evt);
- return;
- }
-
- final MessageEvent event = (MessageEvent) evt;
- Object message = event.getMessage();
+ public void channelRead(final ChannelHandlerContext ctx, Object message) throws Exception {
if (message instanceof Position) {
final Position position = (Position) message;
if ((position.getOutdated() || processInvalidPositions && !position.getValid())
@@ -63,20 +55,20 @@ public class GeolocationHandler implements ChannelUpstreamHandler {
position.setSpeed(0);
position.setCourse(0);
position.set(Position.KEY_RSSI, 0);
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
}
@Override
public void onFailure(Throwable e) {
Log.warning(e);
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
}
});
} else {
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
}
} else {
- Channels.fireMessageReceived(ctx, message, event.getRemoteAddress());
+ ctx.fireChannelRead(message);
}
}