WebSockets as a communication technology wins increasing importance.
In the SAMPLES namespace, you find a nice example for running a WebSocket Server.
There is also a useful example for a Browser Client. But it is still in the browser.
My point is:
How to consume the output of a WebSocket Server in your application?
You may take the engineering approach and use the available tools and classes to handle
everything around protocol switching, encoding, encryption, ....
It is great if you are able to achieve this and if you are willing to invest the required time and find a sponsor to support it.
On the other hand, this is re-inventing the wheel. This works already done in almost every browser.
So I took a closer look of the CSP page included in SAMPLES and modified it to handle the request
and return the result to the Caché server using the good old Hyperevent.
2 issues required more investigation:
- How to launch the page on the browser without manual intervention?
- How to terminate the browser / tab after completion.
Launching the browser was solved once I found the location of the browser exe.
Then starting it using CPIPE or $ZF(-1,...) [or the new $ZF?? for newer versions ] worked immediately.
You compose your string from BrowserLocation_CSPpage_ InquiryMessage and of it goes:
// either do $zf(-1,browser_page_msg) // or open dev:browser_page_msg:0 write $t close dev
You have to be aware that all this an asynchronous environment and you have to check completion more than once.
It is an example and it should help you to adapt it to your individual needs.
You find the code and some more documentation on Open Exchange.