From f5ab3489c9abdc825dd5297829119813740e32e6 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 15 Dec 2015 14:51:57 +1300 Subject: Use web socket instead of long polling --- src/org/traccar/api/AsyncSocket.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/org/traccar/api/AsyncSocket.java b/src/org/traccar/api/AsyncSocket.java index fe20081d3..7de182d7e 100644 --- a/src/org/traccar/api/AsyncSocket.java +++ b/src/org/traccar/api/AsyncSocket.java @@ -66,9 +66,11 @@ public class AsyncSocket extends WebSocketAdapter implements ConnectionManager.U } private void sendData(String key, Collection data) { - JsonObjectBuilder json = Json.createObjectBuilder(); - json.add(key, JsonConverter.arrayToJson(data)); - getRemote().sendString(json.build().toString(), null); + if (!data.isEmpty()) { + JsonObjectBuilder json = Json.createObjectBuilder(); + json.add(key, JsonConverter.arrayToJson(data)); + getRemote().sendString(json.build().toString(), null); + } } } -- cgit v1.2.3