If the contents of your feed can be controlled, then the
simple StockList demo Adapter example doesn't match well, because in that case our simulated feed sends everything and the Data Adapter extracts the quotes related to the current subscriptions.
The
JMS Adapter example is more similar, since the Adapter receives the subscription requests and forwards the requests to the feed; but it also introduces several complications.
So, I'm afraid we don't have suitable ready-made code.
What your Data Adapter should do is quite simple in principle. You should:
- Upon the invocation of init() from Lightstreamer, open the websocket with the feed and start listening. Since you haven't requested any symbol, I expect that you shouldn't receive anything.
- Upon an invocation of subscribe(item) from Lightstreamer, send a request to the feed to add the related item (i.e. symbol). From that moment you will receive updates from the websocket for that symbol and you should extract the relevant information and forward them to the Lightstreamer listener.
- Similarly, upon an invocation of unsubscribe(item) from Lightstreamer, send a request the feed to stop with the related item (i.e. symbol).
A complication is brought if you also need to handle the "snapshot".
In practice, when you request your feed to add a symbol, does it immediately send through the websocket the current quotation of the symbol? or does it send events only upon quotation changes?