Skip to content

Commit 280edb4

Browse files
authored
Merge pull request #20 from lucee/LDEV-6277-getSession
LDEV-6277: expose wsClient.getSession()
2 parents cd33cf1 + de8ac31 commit 280edb4

5 files changed

Lines changed: 16 additions & 5 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,7 @@ jobs:
257257
echo "Running integration tests on Lucee ${{ matrix.lucee }}..."
258258
FAILED=false
259259
RESULTS=""
260-
# test-session-access parked pending LDEV-6277 (wsClient.getSession() not exposed) —
261-
# re-add once the Java fix lands
262-
for test in test-websocket-client test-lifecycle-callbacks test-return-value-send test-wsclient-broadcast test-wsclients-plural test-binary-send test-close test-onfirstopen-rearm test-onopen-async test-request-timeout; do
260+
for test in test-websocket-client test-lifecycle-callbacks test-return-value-send test-wsclient-broadcast test-wsclients-plural test-binary-send test-close test-session-access test-onfirstopen-rearm test-onopen-async test-request-timeout; do
263261
echo ""
264262
echo "=============================================="
265263
echo "Running ${test}"
@@ -352,7 +350,7 @@ jobs:
352350
echo '```' >> $GITHUB_STEP_SUMMARY
353351
cat /tmp/integration-results.txt >> $GITHUB_STEP_SUMMARY || true
354352
echo '```' >> $GITHUB_STEP_SUMMARY
355-
for test in test-websocket-client test-lifecycle-callbacks test-return-value-send test-wsclient-broadcast test-wsclients-plural test-binary-send test-close test-onfirstopen-rearm test-onopen-async test-request-timeout; do
353+
for test in test-websocket-client test-lifecycle-callbacks test-return-value-send test-wsclient-broadcast test-wsclients-plural test-binary-send test-close test-session-access test-onfirstopen-rearm test-onopen-async test-request-timeout; do
356354
if [ -f /tmp/${test}.txt ] && grep -q "FAILED" /tmp/${test}.txt; then
357355
echo "" >> $GITHUB_STEP_SUMMARY
358356
echo "#### ${test}" >> $GITHUB_STEP_SUMMARY

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 3.0.0.21 (unreleased)
44

5+
- [LDEV-6277](https://luceeserver.atlassian.net/browse/LDEV-6277) — expose `wsClient.getSession()` so listeners can reach the underlying JSR-356 `Session` (`getId()`, `getUserProperties()`, `getRequestParameterMap()`)
56
- [LDEV-6221](https://luceeserver.atlassian.net/browse/LDEV-6221) — improve reflection fallback warning message to explain why and that a servlet engine restart is needed
67

78
## 3.0.0.20

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ LUCEE_EXTENSIONS=org.lucee:websocket-extension:3.0.0.20-SNAPSHOT
2424

2525
- **Listener components** — CFML components with `onOpen`, `onMessage`, `onClose`, `onError`, `onFirstOpen`, `onLastClose` lifecycle methods.
2626
- **Async open handler** — optional `onOpenAsync` runs in parallel with `onOpen` for long-running init work.
27+
- **JSR-356 Session access**`wsClient.getSession()` exposes the underlying `javax.websocket.Session` / `jakarta.websocket.Session` for per-connection state (`getUserProperties()`), connection identity (`getId()`), and handshake data (`getRequestParameterMap()`).
2728
- **`websocketInfo()` BIF** — returns `version`, `mapping`, `config`, `configFile`, `log`, and an `instances[]` array of active sessions with their component + session metadata.
2829
- **Extension hot-upgrade** — upgrade the `.lex` in-place via `inject()` without restarting the servlet container.
2930
- **Configurable timeouts**`idleTimeout` and `requestTimeout` per web context via `websocket.json`.

source/java/src/org/lucee/extension/websocket/client/AbsWSClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public abstract class AbsWSClient implements Objects {
4444
protected Key IS_CLOSE;
4545
protected Key SIZE;
4646
protected Key GET_CLIENTS;
47+
protected Key GET_SESSION;
4748

4849
protected final WebSocketEndpointFactory factory;
4950
private String className;
@@ -61,6 +62,7 @@ public AbsWSClient(WebSocketEndpointFactory factory, String className) {
6162
IS_CLOSE = caster.toKey("isClose");
6263
SIZE = caster.toKey("size");
6364
GET_CLIENTS = caster.toKey("getClients");
65+
GET_SESSION = caster.toKey("getSession");
6466
}
6567

6668
@Override

source/java/src/org/lucee/extension/websocket/client/WSClient.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public final class WSClient extends AbsWSClient {
1919
public WSClient(WebSocketEndpointFactory factory, Object session) {
2020
super(factory, "WSClient");
2121
this.session = session;
22-
keys = new Key[] { BROADCAST_MESSAGE, CLOSE, IS_OPEN, SEND_MESSAGE };
22+
keys = new Key[] { BROADCAST_MESSAGE, CLOSE, GET_SESSION, IS_OPEN, SEND_MESSAGE };
2323
}
2424

2525
@Override
@@ -51,6 +51,10 @@ else if (CLOSE.equals(name)) {
5151
throw caster.toPageException(e);
5252
}
5353
}
54+
else if (GET_SESSION.equals(name)) {
55+
checkArgs(name, args, 0);
56+
return session;
57+
}
5458

5559
throw exception.createExpressionException("WSClient does not have the function [" + name + "]");
5660
}
@@ -78,6 +82,9 @@ else if (CLOSE.equals(name)) {
7882
throw caster.toPageException(e);
7983
}
8084
}
85+
else if (GET_SESSION.equals(name)) {
86+
return session;
87+
}
8188
throw exception.createExpressionException("WSClient does not have the function [" + name + "]");
8289
}
8390

@@ -95,6 +102,8 @@ public String toString() {
95102

96103
+ "\n\tclose():void;"
97104

105+
+ "\n\tgetSession():Session;"
106+
98107
+ "\n}";
99108
}
100109

0 commit comments

Comments
 (0)