aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/AsyncSocket.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/api/AsyncSocket.java')
-rw-r--r--src/org/traccar/api/AsyncSocket.java8
1 files changed, 5 insertions, 3 deletions
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);
+ }
}
}