aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/ConnectionManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-16 11:46:59 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-16 11:46:59 +1300
commit306098fbeda545babb2c48c80e7fe98e22abb801 (patch)
treea249093233a50a9e08cb3f0e77714ce3e7e1933b /src/org/traccar/database/ConnectionManager.java
parentc7d721cfc55b614ab4bf3d656381b7b590ae99e9 (diff)
downloadtrackermap-server-306098fbeda545babb2c48c80e7fe98e22abb801.tar.gz
trackermap-server-306098fbeda545babb2c48c80e7fe98e22abb801.tar.bz2
trackermap-server-306098fbeda545babb2c48c80e7fe98e22abb801.zip
Update device status in the database
Diffstat (limited to 'src/org/traccar/database/ConnectionManager.java')
-rw-r--r--src/org/traccar/database/ConnectionManager.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index 450f2f61f..cb7b4b6d8 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.jboss.netty.channel.Channel;
+import org.traccar.Context;
import org.traccar.Protocol;
import org.traccar.helper.Log;
import org.traccar.model.Device;
@@ -68,9 +69,17 @@ public class ConnectionManager {
}
public synchronized void updateDevice(long deviceId, String status, Date time) {
- // TODO update cache and call listener
- /*Log.debug(deviceId + " " + status + " "
- + new SimpleDateFormat(Log.DATE_FORMAT).format(time));*/
+ Device device = Context.getIdentityManager().getDeviceById(deviceId);
+ device.setStatus(status);
+ device.setLastUpdate(time);
+
+ try {
+ Context.getDataManager().updateDeviceStatus(device);
+ } catch (SQLException error) {
+ Log.warning(error);
+ }
+
+ // TODO call listener
}
public synchronized void updatePosition(Position position) {