aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/AsyncSocket.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-11 14:27:01 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-11 14:27:01 -0700
commit4025a42c42e34bb620f4263de05781a10ddc7a9d (patch)
tree56ec382fcb2ad9089556ab3e17f3d9e76a8ec71e /src/main/java/org/traccar/api/AsyncSocket.java
parentaa00ed23f96f91cfc879f02e61333511e3b7b11b (diff)
downloadtrackermap-server-4025a42c42e34bb620f4263de05781a10ddc7a9d.tar.gz
trackermap-server-4025a42c42e34bb620f4263de05781a10ddc7a9d.tar.bz2
trackermap-server-4025a42c42e34bb620f4263de05781a10ddc7a9d.zip
Inject object mapper
Diffstat (limited to 'src/main/java/org/traccar/api/AsyncSocket.java')
-rw-r--r--src/main/java/org/traccar/api/AsyncSocket.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/api/AsyncSocket.java b/src/main/java/org/traccar/api/AsyncSocket.java
index b5902c4fb..2b866176b 100644
--- a/src/main/java/org/traccar/api/AsyncSocket.java
+++ b/src/main/java/org/traccar/api/AsyncSocket.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2021 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2022 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
package org.traccar.api;
import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.slf4j.Logger;
@@ -39,9 +40,11 @@ public class AsyncSocket extends WebSocketAdapter implements ConnectionManager.U
private static final String KEY_POSITIONS = "positions";
private static final String KEY_EVENTS = "events";
+ private final ObjectMapper objectMapper;
private final long userId;
- public AsyncSocket(long userId) {
+ public AsyncSocket(ObjectMapper objectMapper, long userId) {
+ this.objectMapper = objectMapper;
this.userId = userId;
}
@@ -92,7 +95,7 @@ public class AsyncSocket extends WebSocketAdapter implements ConnectionManager.U
private void sendData(Map<String, Collection<?>> data) {
if (isConnected()) {
try {
- getRemote().sendString(Context.getObjectMapper().writeValueAsString(data), null);
+ getRemote().sendString(objectMapper.writeValueAsString(data), null);
} catch (JsonProcessingException e) {
LOGGER.warn("Socket JSON formatting error", e);
}