diff options
author | 2021-10-25 11:37:04 +0200 | |
---|---|---|
committer | 2021-10-31 19:26:11 +0100 | |
commit | 8f97866dfb5303eca7e7344db8e377a60a481d1f (patch) | |
tree | 9e655f090c36cc2dc456bd2c6a0b6f9c44894076 /language-web/src/main/java/tools | |
parent | feat(web): add xtext websocket client (diff) | |
download | refinery-8f97866dfb5303eca7e7344db8e377a60a481d1f.tar.gz refinery-8f97866dfb5303eca7e7344db8e377a60a481d1f.tar.zst refinery-8f97866dfb5303eca7e7344db8e377a60a481d1f.zip |
feat(web): application-level pings
Diffstat (limited to 'language-web/src/main/java/tools')
3 files changed, 50 insertions, 1 deletions
diff --git a/language-web/src/main/java/tools/refinery/language/web/xtext/server/PongResult.java b/language-web/src/main/java/tools/refinery/language/web/xtext/server/PongResult.java new file mode 100644 index 00000000..fe510f51 --- /dev/null +++ b/language-web/src/main/java/tools/refinery/language/web/xtext/server/PongResult.java | |||
@@ -0,0 +1,44 @@ | |||
1 | package tools.refinery.language.web.xtext.server; | ||
2 | |||
3 | import java.util.Objects; | ||
4 | |||
5 | import org.eclipse.xtext.web.server.IServiceResult; | ||
6 | |||
7 | public class PongResult implements IServiceResult { | ||
8 | private String pong; | ||
9 | |||
10 | public PongResult(String pong) { | ||
11 | super(); | ||
12 | this.pong = pong; | ||
13 | } | ||
14 | |||
15 | public String getPong() { | ||
16 | return pong; | ||
17 | } | ||
18 | |||
19 | public void setPong(String pong) { | ||
20 | this.pong = pong; | ||
21 | } | ||
22 | |||
23 | @Override | ||
24 | public int hashCode() { | ||
25 | return Objects.hash(pong); | ||
26 | } | ||
27 | |||
28 | @Override | ||
29 | public boolean equals(Object obj) { | ||
30 | if (this == obj) | ||
31 | return true; | ||
32 | if (obj == null) | ||
33 | return false; | ||
34 | if (getClass() != obj.getClass()) | ||
35 | return false; | ||
36 | PongResult other = (PongResult) obj; | ||
37 | return Objects.equals(pong, other.pong); | ||
38 | } | ||
39 | |||
40 | @Override | ||
41 | public String toString() { | ||
42 | return "PongResult [pong=" + pong + "]"; | ||
43 | } | ||
44 | } | ||
diff --git a/language-web/src/main/java/tools/refinery/language/web/xtext/server/TransactionExecutor.java b/language-web/src/main/java/tools/refinery/language/web/xtext/server/TransactionExecutor.java index f2f26d98..335f0636 100644 --- a/language-web/src/main/java/tools/refinery/language/web/xtext/server/TransactionExecutor.java +++ b/language-web/src/main/java/tools/refinery/language/web/xtext/server/TransactionExecutor.java | |||
@@ -46,6 +46,11 @@ public class TransactionExecutor implements IDisposable, PrecomputationListener | |||
46 | 46 | ||
47 | public void handleRequest(XtextWebRequest request) throws ResponseHandlerException { | 47 | public void handleRequest(XtextWebRequest request) throws ResponseHandlerException { |
48 | var serviceContext = new SimpleServiceContext(session, request.getRequestData()); | 48 | var serviceContext = new SimpleServiceContext(session, request.getRequestData()); |
49 | var ping = serviceContext.getParameter("ping"); | ||
50 | if (ping != null) { | ||
51 | responseHandler.onResponse(new XtextWebOkResponse(request, new PongResult(ping))); | ||
52 | return; | ||
53 | } | ||
49 | try { | 54 | try { |
50 | var injector = getInjector(serviceContext); | 55 | var injector = getInjector(serviceContext); |
51 | var serviceDispatcher = injector.getInstance(XtextServiceDispatcher.class); | 56 | var serviceDispatcher = injector.getInstance(XtextServiceDispatcher.class); |
diff --git a/language-web/src/main/java/tools/refinery/language/web/xtext/servlet/XtextWebSocketServlet.java b/language-web/src/main/java/tools/refinery/language/web/xtext/servlet/XtextWebSocketServlet.java index 6d4d2cad..942ca380 100644 --- a/language-web/src/main/java/tools/refinery/language/web/xtext/servlet/XtextWebSocketServlet.java +++ b/language-web/src/main/java/tools/refinery/language/web/xtext/servlet/XtextWebSocketServlet.java | |||
@@ -31,7 +31,7 @@ public abstract class XtextWebSocketServlet extends JettyWebSocketServlet implem | |||
31 | */ | 31 | */ |
32 | private static final long MAX_FRAME_SIZE = 4L * 1024L * 1024L; | 32 | private static final long MAX_FRAME_SIZE = 4L * 1024L * 1024L; |
33 | 33 | ||
34 | private static final Duration IDLE_TIMEOUT = Duration.ofMinutes(10); | 34 | private static final Duration IDLE_TIMEOUT = Duration.ofSeconds(30); |
35 | 35 | ||
36 | private transient Logger log = LoggerFactory.getLogger(getClass()); | 36 | private transient Logger log = LoggerFactory.getLogger(getClass()); |
37 | 37 | ||