Comment on page
Websocket
Websocket publisher transport emits processed events to subscribed clients. Events are serialised as Json using the JsonStreamEventFormatter.
io.javalin:javalin:5.4.2
websocketPublisher:
pathOverride: /joule/websocket/stream
This simple example leverages the default setting resulting in events published as StreamEvent Json object to connected clients.
Use the below example to validate websocket data streaming. If you are using Chrome open up the Developer tools console tab and click the
Start Streaming
button on the page to stream events from the Joule process. <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebSocket Client</title>
</head>
<body>
<button onclick="contactServer">Start Streaming</button>
</body>
<script>
const socket = new WebSocket('ws://localhost:7070/joule/websocket/stream');
socket.addEventListener('open', function (event) {
socket.send('Connection Established');
});
socket.addEventListener('message', function (event) {
console.log(event.data);
});
const contactServer = () => {
socket.send("Initialize");
}
</script>
</html>
Available configuration parameters
Attribute | Description | Data Type | Required |
---|---|---|---|
pathOverride | User defined path | String Default: /joule/websocket/stream |
Last modified 7mo ago