0
我是新來的高速公路概念,我想了解如何將推送api的數據流直接推送到網頁中。高速公路:從推送api到網頁顯示實時流
下面的代碼給出了控制檯輸出的實時流。我想在網頁上顯示它。
var autobahn = require('autobahn');
var wsuri = "wss://api.poloniex.com";
var connection = new autobahn.Connection({
url: wsuri,
realm: "realm1"
});
connection.onopen = function (session) {
function marketEvent (args,kwargs) {
console.log(args);
}
session.subscribe('BTC_XMR', marketEvent);
function tickerEvent (args,kwargs) {
console.log(args);
}
function trollboxEvent (args,kwargs) {
console.log(args);
}
session.subscribe('ticker', tickerEvent);
session.subscribe('trollbox', trollboxEvent);
}
connection.onclose = function() {
console.log("Websocket connection closed");
}
connection.open();