Websockets
Websockets are web protocols that allow clients and servers to communicate bi-directionally in realtime over a persistent TCP connection. All messages sent across a WebSocket connection are asynchronous.
Async call via websockets
- Take the code from the appendix and create two files in the same directory:
- getMemWS.html
- c.js
Within the HTML code, it takes user input, opens a handle to the kxw_qr_gw
service and executes the .mon.getMemWS
analytic with the input parameters.
- In
getMemWS.html
, change the host and port tailored to your environment. The port should be addressing a runningkxw_qr_gw
process.
ws = new WebSocket("ws://HOST:PORT/");
-
Open the
getMemWS.html
on a browser. -
Right-click > Inspect > Console. If a connection is successfully made, these should be printed to your console:
- Change the parameter values and hit submit. Results should be returned as a table on screen.