StefanBD
StefanBD

Reputation: 344

Lightstreamer set connection options in JS

Hello i try to understand this lib and i have a python source here https://github.com/ig-python/ig-markets-api-python-library/blob/master/trading_ig/lightstreamer.py on line 187 I'm able to add LS_op2 or set LS_container but I have problems on doing this on the js version.

the first message i want is:

LS_op2=create&LS_phase=5701&LS_cause=new.api&LS_polling=true&LS_polling_millis=0&LS_idle_millis=0&LS_cid=pcYgxn8m8 feOojy*****f3g2.pz479mDv&LS_adapter_set=DEMO&LS_container=lsc&

but i get only

LS_phase=3201&LS_cause=new.nullresp&LS_polling=true&LS_polling_millis=0&LS_idle_millis=0&LS_cid=pcYgxn*** feOojyA1U661i3g2.pz47Af6k&LS_adapter_set=DEMO&

Maybe someone have a idea, here is my source, thanks.

  <html>
<head>
    <script src="https://unpkg.com/[email protected]/lightstreamer.min.js"></script>
    <script>
        document.addEventListener("DOMContentLoaded", function(event) {
            var client = new LightstreamerClient("https://push.lightstreamer.com","DEMO");

            client.connect();
            var sub = new Subscription("MERGE",["item1","item2","item3"],["stock_name","last_price"]);
            sub.setDataAdapter("QUOTE_ADAPTER");
            sub.setRequestedSnapshot("yes");

            sub.addListener({
                onItemUpdate: function(obj) {
                   console.log(obj.getValue("stock_name") + ": " + obj.getValue("last_price"));
                }
            });
            client.subscribe(sub);
        });

    </script>
</head>
<body>
</body>
</html>

Upvotes: 0

Views: 307

Answers (1)

Dario from LS
Dario from LS

Reputation: 81

If the question is why Lightstreamer javascript SDK 8.0.3 library creates a different request, it is because the python code provided as reference (which doesn't lean on any SDK library) uses an earlier version of the communication protocol. Anyway, the request issued by the javascript library is supposed to work.

Upvotes: 0

Related Questions