簡體   English   中英

Lightstreamer 在 JS 中設置連接選項

[英]Lightstreamer set connection options in JS

您好,我嘗試理解這個庫,我在第 187 行有一個 python 源代碼https://github.com/ig-python/ig-markets-api-python-library/blob/master/trading_ig/lightstreamer.py我能夠添加 LS_op2 或設置 LS_container 但我在 js 版本上執行此操作時遇到問題。

我想要的第一條信息是:

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&

但我只得到

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&

也許有人有想法,這是我的來源,謝謝。

  <html>
<head>
    <script src="https://unpkg.com/lightstreamer-client-web@8.0.3/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>

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. 無論如何,javascript 庫發出的請求應該可以工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM