• General
  • Request/Reply RPC style communication using Light Streamer Websockets.

Hi,

We have a requirement to establish an RPC style communication between a client and a server using Websockets. The server is an online ordering solution which needs to submit orders to over 5000 point of sales systems (POS) all over the US.

We downloaded your software and did some POC, however we are unable to find out how we can do a synchronous request/reply between the server and the client. In our case the server needs to issue the following calls to the client (POS) and get a reply on the same thread synchronously
  1. Call the POS to get the customer's personal information
  2. Post the credit card data and the order data to the POS and get a confirmation on the same thread
Is it possible to do RPC style communication using your product?

Thanks in Advance
Hi,

I confirm there is no such direct way to do request/reply with Lightstreamer. You should use the sendMessage for the request and use a dedicated item to get asynchronous responses.

A trick could be used to obtain the request/reply infrastructure but we do not officially suggest to use it as it may create confusion in the error handling code. When you receive a message from a client you can handle it by throwing a CreditsException: the code and message of the exception are forwarded to the client and exposed by our API

[SYNTAX=JAVA]
throw new CreditsException(number, "response");
[/SYNTAX]

[SYNTAX=JS] lsClient.sendMessage("request", "seq", timeout, {
onDeny: function(originalMex, code, message) {
//handle the response

}
});
[/SYNTAX]
Note that the same facilities are available on all the SDKs.

In the future, the sendMessage infrastructure will be extended to support custom messages on the OK responses (but not in the very short term).

see
http://www.lightstreamer.com/docs/client_javascript_uni_api/LightstreamerClient.html#sendMessage
http://www.lightstreamer.com/docs/client_javascript_uni_api/ClientMessageListener.html
http://www.lightstreamer.com/docs/adapter_java_api/com/lightstreamer/interfaces/metadata/MetadataProvider.html#notifyUserMessage(java.lang.String, java.lang.String, java.lang.String)
http://www.lightstreamer.com/docs/adapter_java_api/com/lightstreamer/interfaces/metadata/CreditsException.html