diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-11 14:27:01 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-11 14:27:01 -0700 |
commit | 4025a42c42e34bb620f4263de05781a10ddc7a9d (patch) | |
tree | 56ec382fcb2ad9089556ab3e17f3d9e76a8ec71e /src/main/java/org/traccar/api/AsyncSocketServlet.java | |
parent | aa00ed23f96f91cfc879f02e61333511e3b7b11b (diff) | |
download | trackermap-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/AsyncSocketServlet.java')
-rw-r--r-- | src/main/java/org/traccar/api/AsyncSocketServlet.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/api/AsyncSocketServlet.java b/src/main/java/org/traccar/api/AsyncSocketServlet.java index a964ead10..4e55dfebf 100644 --- a/src/main/java/org/traccar/api/AsyncSocketServlet.java +++ b/src/main/java/org/traccar/api/AsyncSocketServlet.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. @@ -15,24 +15,33 @@ */ package org.traccar.api; +import com.fasterxml.jackson.databind.ObjectMapper; import org.eclipse.jetty.websocket.server.JettyWebSocketServlet; import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory; import org.traccar.Context; import org.traccar.api.resource.SessionResource; import org.traccar.config.Keys; +import javax.inject.Inject; import javax.servlet.http.HttpSession; import java.time.Duration; public class AsyncSocketServlet extends JettyWebSocketServlet { + private final ObjectMapper objectMapper; + + @Inject + public AsyncSocketServlet(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + @Override public void configure(JettyWebSocketServletFactory factory) { factory.setIdleTimeout(Duration.ofMillis(Context.getConfig().getLong(Keys.WEB_TIMEOUT))); factory.setCreator((req, resp) -> { if (req.getSession() != null) { long userId = (Long) ((HttpSession) req.getSession()).getAttribute(SessionResource.USER_ID_KEY); - return new AsyncSocket(userId); + return new AsyncSocket(objectMapper, userId); } else { return null; } |