Connect to a Prism realtime server
Connect to a Prism Server from the browser or a remote Node app.
var prismClient = require'prism-client';var rtt = require'rtt-engineio';var transport = rttclientport: 3001 host: 'localhost';var app = prismClient;appconnectconsole.log"Connected to Prism Server %s with Session ID %s" infoversion infosessionId;appdiscoverconsole.log'Available services are' appapi;;;
Please see the REPL client example in
Note: Not all transports support Node.js clients.
I've not tried this yet, but in theory it should be possible. You may need to use PersistJS. Please get in touch to let me know how you get on.
Client's can either be told what services are available in advance (using
app.provide()), or discover them upon connection (using
We recommending providing service info in advance where possible as this minimizes the traffic over the WebSocket. It also allows for the client-side code to be minimized and served by CDNs.
Prism Server can make this easy for you by building a custom client module containing all the code you need for the transport and services. Just call
However it's not always possible to know what Services are provided by a server until you connect. For example, you may want to run a query over the REPL against a remote server. In this case, you'll need to call
app.discover() upon initial connection.