diff --git a/test/servers/ws/README.md b/test/servers/ws/README.md index f1b78ae8..fbb62333 100644 --- a/test/servers/ws/README.md +++ b/test/servers/ws/README.md @@ -1,10 +1,10 @@ # WebSocket - Test Server -This package implements a bare-bones WebSocket server for testing htmx. It can be used in conjunction with the manual tests in the `/test/manual` directory. +This package implements a test-suite WebSocket server for testing htmx. ## What It Does -This listens for incoming WebSocket connections coming in to ws://localhost:1323/echo. When it receives messages from any WebSocket client, it responds with that same content in a way that htmx can process. This means, that the response message will look like this: `
As of version 1.7, WebSocket support has been moved out of the core htmx library and into an extension. This server runs a test suite for the htmx WebSocket extension.
+This extension connects to a WebSocket echo server and can send and receive messages to and from the server.
+ +hx-ext | +Make sure the SSE extension is initialized on every page or page fragment where you use SSE streams. | +
ws-connect | +Connects to a WebSocket server. Attribute value must begin with ws:// wss:// | +
ws-send | +Add to a form to submit form data to the websocket server instead of to an HTTP server. | +
+<body hx-ext="ws"> + <div ws-connect="wss://my.websocket.server.com"></div> + + <form ws-send> + <input name="WebSocketMessage"> + <form/> +</body> ++
This test lets you send and receive data to and from the WebSocket server. Every message that you send to the server will be "echoed" +back to you in a separate message
+ ++<div hx-ext="ws" ws-connect="ws://localhost/echo"> + + <form ws-send> + <input type="text" name="message" style="width:500px;" value="This Is The Message" /> + <input type="submit"/> + </form> + + <div id="idMessage"></div> +</div> ++ +
This test receives messages from the WebSocket server every second. + +
+<div hx-ext="ws" ws-connect="ws://localhost/heartbeat"> + <div id="idMessage"></div> +</div> ++ +
Each message just contains a random number generated by the server
+