aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/api')
-rw-r--r--src/main/java/org/traccar/api/AsyncSocket.java7
-rw-r--r--src/main/java/org/traccar/api/resource/DeviceResource.java4
2 files changed, 5 insertions, 6 deletions
diff --git a/src/main/java/org/traccar/api/AsyncSocket.java b/src/main/java/org/traccar/api/AsyncSocket.java
index 40aa68e88..5fc4b4412 100644
--- a/src/main/java/org/traccar/api/AsyncSocket.java
+++ b/src/main/java/org/traccar/api/AsyncSocket.java
@@ -58,15 +58,14 @@ public class AsyncSocket extends WebSocketAdapter implements ConnectionManager.U
public void onWebSocketConnect(Session session) {
super.onWebSocketConnect(session);
- Map<String, Collection<?>> data = new HashMap<>();
try {
+ Map<String, Collection<?>> data = new HashMap<>();
data.put(KEY_POSITIONS, PositionUtil.getLatestPositions(storage, userId));
+ sendData(data);
+ connectionManager.addListener(userId, this);
} catch (StorageException e) {
throw new RuntimeException(e);
}
- sendData(data);
-
- connectionManager.addListener(userId, this);
}
@Override
diff --git a/src/main/java/org/traccar/api/resource/DeviceResource.java b/src/main/java/org/traccar/api/resource/DeviceResource.java
index 2b673a108..e205f2d28 100644
--- a/src/main/java/org/traccar/api/resource/DeviceResource.java
+++ b/src/main/java/org/traccar/api/resource/DeviceResource.java
@@ -137,8 +137,8 @@ public class DeviceResource extends BaseObjectResource<Device> {
try {
cacheManager.addDevice(position.getDeviceId());
cacheManager.updatePosition(position);
- connectionManager.updatePosition(position);
- broadcastService.updatePosition(position);
+ connectionManager.updatePosition(true, position);
+ broadcastService.updatePosition(true, position);
} finally {
cacheManager.removeDevice(position.getDeviceId());
}