aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/AsyncSocketServlet.java
diff options
context:
space:
mode:
authorkamaci <furkankamaci@gmail.com>2020-10-19 00:01:12 +0300
committerkamaci <furkankamaci@gmail.com>2020-10-19 00:01:12 +0300
commit3cd7831692b1725713e297372a0181e5ae614eb9 (patch)
tree46725cd3575e53ff9ff40b44236b34a323f804ac /src/main/java/org/traccar/api/AsyncSocketServlet.java
parent98c2e3da5ea0670360078a3f278ddef7d9e39953 (diff)
downloadtrackermap-server-3cd7831692b1725713e297372a0181e5ae614eb9.tar.gz
trackermap-server-3cd7831692b1725713e297372a0181e5ae614eb9.tar.bz2
trackermap-server-3cd7831692b1725713e297372a0181e5ae614eb9.zip
Anonymous types are replaced with lambda.
Diffstat (limited to 'src/main/java/org/traccar/api/AsyncSocketServlet.java')
-rw-r--r--src/main/java/org/traccar/api/AsyncSocketServlet.java18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/main/java/org/traccar/api/AsyncSocketServlet.java b/src/main/java/org/traccar/api/AsyncSocketServlet.java
index 9318b6fc6..51fbfb478 100644
--- a/src/main/java/org/traccar/api/AsyncSocketServlet.java
+++ b/src/main/java/org/traccar/api/AsyncSocketServlet.java
@@ -15,9 +15,6 @@
*/
package org.traccar.api;
-import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest;
-import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse;
-import org.eclipse.jetty.websocket.servlet.WebSocketCreator;
import org.eclipse.jetty.websocket.servlet.WebSocketServlet;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
import org.traccar.Context;
@@ -30,15 +27,12 @@ public class AsyncSocketServlet extends WebSocketServlet {
@Override
public void configure(WebSocketServletFactory factory) {
factory.getPolicy().setIdleTimeout(Context.getConfig().getLong("web.timeout", ASYNC_TIMEOUT));
- factory.setCreator(new WebSocketCreator() {
- @Override
- public Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp) {
- if (req.getSession() != null) {
- long userId = (Long) req.getSession().getAttribute(SessionResource.USER_ID_KEY);
- return new AsyncSocket(userId);
- } else {
- return null;
- }
+ factory.setCreator((req, resp) -> {
+ if (req.getSession() != null) {
+ long userId = (Long) req.getSession().getAttribute(SessionResource.USER_ID_KEY);
+ return new AsyncSocket(userId);
+ } else {
+ return null;
}
});
}