aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-04-04 15:38:42 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-04-04 15:38:42 -0700
commit7bea8d52acd3d9cd1fa9502229cc38faac6cf7bc (patch)
tree1f64a6ddf0d187a1f932aff93cd8ed8ea9582cef /src/main/java/org/traccar/api
parent92dc10c476141c4c524c07d6625009a8c6071c87 (diff)
downloadtraccar-server-7bea8d52acd3d9cd1fa9502229cc38faac6cf7bc.tar.gz
traccar-server-7bea8d52acd3d9cd1fa9502229cc38faac6cf7bc.tar.bz2
traccar-server-7bea8d52acd3d9cd1fa9502229cc38faac6cf7bc.zip
Upgrade Jetty web server
Diffstat (limited to 'src/main/java/org/traccar/api')
-rw-r--r--src/main/java/org/traccar/api/AsyncSocketServlet.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/api/AsyncSocketServlet.java b/src/main/java/org/traccar/api/AsyncSocketServlet.java
index 490fc89fc..a964ead10 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 - 2020 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2021 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,20 +15,23 @@
*/
package org.traccar.api;
-import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
-import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
+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;
-public class AsyncSocketServlet extends WebSocketServlet {
+import javax.servlet.http.HttpSession;
+import java.time.Duration;
+
+public class AsyncSocketServlet extends JettyWebSocketServlet {
@Override
- public void configure(WebSocketServletFactory factory) {
- factory.getPolicy().setIdleTimeout(Context.getConfig().getLong(Keys.WEB_TIMEOUT));
+ 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) req.getSession().getAttribute(SessionResource.USER_ID_KEY);
+ long userId = (Long) ((HttpSession) req.getSession()).getAttribute(SessionResource.USER_ID_KEY);
return new AsyncSocket(userId);
} else {
return null;