Skip to content

Commit efce09b

Browse files
committed
Update README.md
1 parent 07b2f70 commit efce09b

1 file changed

Lines changed: 70 additions & 11 deletions

File tree

README.md

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,80 @@
1-
# Lucee Websocket Extension
1+
# Lucee WebSocket Extension
22

3-
Provides Websocket support for Lucee
3+
[![Java CI](https://github.com/lucee/extension-websocket/actions/workflows/main.yml/badge.svg)](https://github.com/lucee/extension-websocket/actions/workflows/main.yml)
44

5-
Docs: [https://docs.lucee.org/categories/image.html](https://docs.lucee.org/recipes/websocket-extension.html)
5+
WebSocket server support for Lucee CFML — define listener components with lifecycle methods (`onOpen`, `onMessage`, `onClose`, etc) and Lucee handles the WebSocket endpoint for you.
66

7-
Downloads: https://download.lucee.org/#3F9DFF32-B555-449D-B0EB5DB723044045
7+
**Requires Lucee 6.2+**. Dual API support — loads on both Lucee 6.x (Tomcat 9 / `javax.websocket`) and Lucee 7.x (Tomcat 11 / `jakarta.websocket`).
88

9-
Issues: [https://luceeserver.atlassian.net/issues/?jql=labels%20%3D%20%22websockets%22](https://luceeserver.atlassian.net/issues/?jql=labels%20%3D%20%22websockets%22)
9+
## Installation
1010

11-
A client example using javascript and cfml
11+
Install via Lucee Admin, or pin in your environment:
1212

13-
https://github.com/webonix/Lucee-websocket-commandbox
13+
```bash
14+
LUCEE_EXTENSIONS=org.lucee:websocket-extension:3.0.0.20-SNAPSHOT
15+
```
1416

15-
Presentation at CFCAMP 2024
17+
## Documentation
1618

17-
https://www.cfcamp.org/resource/getting-started-with-lucee-6-websockets.html
19+
- **Docs**: [docs.lucee.org/recipes/websocket-extension.html](https://docs.lucee.org/recipes/websocket-extension.html)
20+
- **Downloads**: [download.lucee.org](https://download.lucee.org/#3F9DFF32-B555-449D-B0EB5DB723044045)
21+
- **Issues**: [Lucee JIRA — WebSocket Issues](https://luceeserver.atlassian.net/issues/?jql=labels%20%3D%20%22websockets%22)
1822

19-
## Websocket Client Extension
23+
### What's Included
2024

21-
https://github.com/lucee/extension-websocket-client
25+
- **Listener components** — CFML components with `onOpen`, `onMessage`, `onClose`, `onError`, `onFirstOpen`, `onLastClose` lifecycle methods.
26+
- **Async open handler** — optional `onOpenAsync` runs in parallel with `onOpen` for long-running init work.
27+
- **`websocketInfo()` BIF** — returns `version`, `mapping`, `config`, `configFile`, `log`, and an `instances[]` array of active sessions with their component + session metadata.
28+
- **Extension hot-upgrade** — upgrade the `.lex` in-place via `inject()` without restarting the servlet container.
29+
- **Configurable timeouts**`idleTimeout` and `requestTimeout` per web context via `websocket.json`.
30+
31+
## Configuration
32+
33+
Listener components live in a directory configured in `{lucee-config}/websocket.json` (auto-created with defaults on first load):
34+
35+
```json
36+
{
37+
"directory": "{lucee-config}/websockets/",
38+
"requestTimeout": 50,
39+
"idleTimeout": 300
40+
}
41+
```
42+
43+
Override the config path with `-Dlucee.websocket.config=/path/to/websocket.json` or the `LUCEE_WEBSOCKET_CONFIG` env var.
44+
45+
## Quick Example
46+
47+
A listener component dropped in the configured directory as `EchoListener.cfc`:
48+
49+
```cfml
50+
component {
51+
52+
function onOpen( wsClient ) {
53+
wsClient.send( "CONNECTED" );
54+
}
55+
56+
function onMessage( wsClient, message ) {
57+
wsClient.send( "ECHO:" & message );
58+
}
59+
60+
function onClose( wsClient, reasonPhrase ) {}
61+
62+
function onError( wsClient, cfCatch ) {
63+
systemOutput( "WS error: #cfCatch.message#", true );
64+
}
65+
66+
}
67+
```
68+
69+
Clients connect to `ws://yourhost/ws/EchoListener`. Check server state:
70+
71+
```cfml
72+
info = websocketInfo();
73+
writeDump( info );
74+
```
75+
76+
## Related
77+
78+
- **[extension-websocket-client](https://github.com/lucee/extension-websocket-client)** — WebSocket client BIFs (`CreateWebSocketClient`) for CFML. This repo's integration tests ([test-websocket-client.cfm](tests/test-websocket-client.cfm), [test-idle-timeout.cfm](tests/test-idle-timeout.cfm)) exercise the full client⇄server loop, so they cover both extensions.
79+
- **[Lucee-websocket-commandbox](https://github.com/webonix/Lucee-websocket-commandbox)** — full client + server example with JavaScript and CFML.
80+
- **[CFCAMP 2024 presentation](https://www.cfcamp.org/resource/getting-started-with-lucee-6-websockets.html)** — Getting Started with Lucee 6 WebSockets.

0 commit comments

Comments
 (0)