Commit 20914281 by ken

试试看

parent 6638a095
// const stream = 'wss://api.zb.com:9999/websocket'; const stream = 'wss://api.zb.com:9999/websocket';
const stream = "wss://kline.zb.com:2443/websocket"; // const stream = "wss://kline.zb.com:2443/websocket";
const WebSocket = require('ws'); const WebSocket = require('ws');
const request = require('request'); const request = require('request');
const crypto = require('ezcrypto').Crypto; const crypto = require('ezcrypto').Crypto;
...@@ -45,11 +45,9 @@ const _handleSocketError = function(error) { ...@@ -45,11 +45,9 @@ const _handleSocketError = function(error) {
}; };
const _handleSocketOpen = function(opened_callback) { const _handleSocketOpen = function(opened_callback) {
this.isAlive = true;
console.log("open"); console.log("open");
for (const symbol of observerSymbol) { for (const symbol of observerSymbol) {
// const req = {event: 'addChannel', channel: symbol + '_depth'}; const req = {event: 'addChannel', channel: symbol + '_depth'};
const req = {event: 'addChannel', channel: 'dish_depth_001_' + symbol + "default", "binary": false};
console.log(JSON.stringify(req)); console.log(JSON.stringify(req));
this.send(JSON.stringify(req)); this.send(JSON.stringify(req));
} }
...@@ -81,7 +79,6 @@ const _subscribe = function(callback, opened_callback = false) { ...@@ -81,7 +79,6 @@ const _subscribe = function(callback, opened_callback = false) {
ws.on('close', _handleSocketClose.bind(ws)); ws.on('close', _handleSocketClose.bind(ws));
ws.on('message', function(data) { ws.on('message', function(data) {
try { try {
console.log(data);
callback(JSON.parse(data)); callback(JSON.parse(data));
} catch (error) { } catch (error) {
console.log('Parse error: '+error.message); console.log('Parse error: '+error.message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment