|
|
|
@ -15,7 +15,6 @@ class Model { |
|
|
|
* @param {Object} unsub_params 取消订阅的参数 |
|
|
|
*/ |
|
|
|
constructor(link, view) { |
|
|
|
|
|
|
|
this.socket = new Socket(link); |
|
|
|
this.view = view; |
|
|
|
|
|
|
|
@ -82,7 +81,11 @@ class Model { |
|
|
|
this.widget = new TradingView.widget(servlet(settings)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//重连WS后的操作
|
|
|
|
conglian(link){ |
|
|
|
this.socket = new Socket(link); |
|
|
|
this.socket.on('message', this.handleMessage.bind(this)); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 发起订阅新的数据 |
|
|
|
* @param {Array|Object} sub_params 所有订阅参数 |
|
|
|
@ -102,12 +105,12 @@ class Model { |
|
|
|
sendMessage(data) { |
|
|
|
// debugger
|
|
|
|
console.log(">>>>>>>>>>" + JSON.stringify(data)); |
|
|
|
|
|
|
|
// 已经open状态
|
|
|
|
if (this.socket.checkOpen()) this.socket.send(data); |
|
|
|
else { |
|
|
|
else{ |
|
|
|
// 先open 再send
|
|
|
|
this.socket.on('open', (evt) => { |
|
|
|
console.info(this.socket) |
|
|
|
this.socket.send(data); |
|
|
|
}) |
|
|
|
} |
|
|
|
@ -119,7 +122,7 @@ class Model { |
|
|
|
|
|
|
|
// 处理历史数据和动态更新的数据
|
|
|
|
handleMessage(response) { |
|
|
|
|
|
|
|
|
|
|
|
// if (response.sub != "history" && response.sub != "dynamic") return;
|
|
|
|
|
|
|
|
let { data = null, sub = null, type = null } = response; |
|
|
|
@ -156,7 +159,6 @@ class Model { |
|
|
|
this.lastTime = list[list.length - 1].time; |
|
|
|
|
|
|
|
} else if (type == "dynamic") { |
|
|
|
|
|
|
|
// 最新的数据值
|
|
|
|
// console.log('<<<<<<<<<New');
|
|
|
|
// 检测是否已经加载历史数据
|
|
|
|
|