diff options
author | Abyss777 <abyss@fox5.ru> | 2016-07-13 19:11:36 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-07-13 19:11:36 +0500 |
commit | 3502e07f0aee825f8599526428dd1962d81f9933 (patch) | |
tree | 546f03304f31ac7db4873cc34f2cceda4acb0b01 /src/org/traccar/notification/EventForwarder.java | |
parent | 1593a9dee20ee7355f9f5feb6d121a5ad69a283f (diff) | |
download | trackermap-server-3502e07f0aee825f8599526428dd1962d81f9933.tar.gz trackermap-server-3502e07f0aee825f8599526428dd1962d81f9933.tar.bz2 trackermap-server-3502e07f0aee825f8599526428dd1962d81f9933.zip |
Renamed to EventForwarder and moved to Context
Diffstat (limited to 'src/org/traccar/notification/EventForwarder.java')
-rw-r--r-- | src/org/traccar/notification/EventForwarder.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/org/traccar/notification/EventForwarder.java b/src/org/traccar/notification/EventForwarder.java index 32f8a1ffc..096026541 100644 --- a/src/org/traccar/notification/EventForwarder.java +++ b/src/org/traccar/notification/EventForwarder.java @@ -14,9 +14,14 @@ import org.traccar.web.JsonConverter; import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder; -public final class NotificationForward { +public final class EventForwarder { - private NotificationForward() { + private String url; + private String header; + + public EventForwarder() { + url = Context.getConfig().getString("event.forward.url", "http://localhost/"); + header = Context.getConfig().getString("event.forward.header", ""); } private static final String USER_AGENT = "Traccar Server"; @@ -26,9 +31,8 @@ public final class NotificationForward { private static final String KEY_GEOFENCE = "geofence"; private static final String KEY_DEVICE = "device"; - public static void forwardEvent(Event event, Position position) { - String url = Context.getConfig().getString("event.forward.url", "http://localhost/"); - String header = Context.getConfig().getString("event.forward.header", ""); + public void forwardEvent(Event event, Position position) { + BoundRequestBuilder requestBuilder = Context.getAsyncHttpClient().preparePost(url); @@ -48,7 +52,7 @@ public final class NotificationForward { requestBuilder.execute(); } - private static byte[] preparePayload(Event event, Position position) { + private byte[] preparePayload(Event event, Position position) { JsonObjectBuilder json = Json.createObjectBuilder(); json.add(KEY_EVENT, JsonConverter.objectToJson(event)); if (position != null) { |