DEV Community

InterSystems Developer for InterSystems

Posted on • Originally published at community.intersystems.com

Client for WebSockets based on Node.js

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. JavaScript does most of the work. 

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 in almost every browser.

e. g JavaScript has excellent and verified libraries to support what you need.

And there is the engine to run it without a browser: Node.js

And Caché, IRIS, Ensemble have meanwhile a well-established interface module ready.

So I took a closer look after managing to get the correct versions together.

Once the WsockDemo.js was assembled and tested you launch it over CPIPE or $ZF(....)

You provide control information from the server and get back the result to the server.

If you are used to JavaScript there are no big surprises. The major difference to accept and

understand is that yo operate in an almost total asynchronous environment and callback

methods and their interaction are probably the most important difference to traditional

programming.

I have placed the example here with more docs as an invitation to break out

(for most developers) of your traditional environment and find something new and useful.

 I have to admit that this was my first exercise into Node.js and I'm far from taking the best

and most advanced solution. But the result in relation to the effort was convincing.  

Remember:

This is a coding example working on Cache 2018.1.3  
 It will not be kept in synch with new versions      
 It is also NOT serviced by InterSystems Support !

Top comments (0)