NewsCompaniesAboutContact usCreate an AccountLoginGo To
Community supported
Works with
CachéEnsembleInterSystems IRIS
Last updated
Version history

What's new in this version


This is a simple example how to use CSP technology together with JavaScript as a Client for WebSocket Servers and to collect the replies in Caché, IRIS, ..

The standard distribution contains in namespace SAMPLES a nice example of a CSP page consuming WebService as Client. I have modified it not only to display the replies but to feed it back to Caché into a Global. I used the classic Hyperevent to achieve this. The replies end up as a log in ^WSREPLY. When there is no input anymore the page closes and goes away.

There are 2 versions with visible and hidden display during operation. websocketreverseV.csp and websocketreverseH.csp

The message to send is simply passed as hash after the CSP_URL. (Mind URL encoding!)

You can launch the page using a command pipe or $zf(-1,...) or similar for newer versions directly out of your application or from command line.

 /// find your browser location
 set browser="""C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"" "
 /// don't forget the # at the end
 set page="http://localhost:57772/csp/samples/websocketreverse.csp#"
 /// whatever you send to the server
 set msg="helloALL"
 /// a CPIPE device
 set dev="|CPIPE|22"

 // either
 do $zf(-1,browser_page_msg)

 // or
 open dev:browser_page_msg:0 write $t close dev

and what you get on server looks like this:

^WSREPLY(34)=$lb("2019-02-08 18:03:11","Welcome to Cache WebSocket. NameSpace: SAMPLES")
^WSREPLY(35)=$lb("2019-02-08 18:03:11","'helloALL' (length=8) recieved on 08 Feb 2019 at 06:03:11PM NameSpace=SAMPLES")
^WSREPLY(36)=$lb("2019-02-08 18:03:21","Timeout after 10 seconds occurred on 08 Feb 2019 at 06:03:21PM")
^WSREPLY(37)=$lb("2019-02-08 18:03:31","Timeout after 10 seconds occurred on 08 Feb 2019 at 06:03:31PM")
^WSREPLY(38)=$lb("2019-02-08 18:03:41","Timeout after 10 seconds occurred on 08 Feb 2019 at 06:03:41PM")
^WSREPLY(39)=$lb("2019-02-08 18:03:41","exit")

This is mainly a starting point to be adapted to you individual needs.