-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
50 lines (45 loc) · 1.49 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
const app = require('./app');
const io = require('socket.io').listen(app);
const appConstant = require('./config/appConstant');
const bittrex = require('node-bittrex-api');
const async = require('async');
var custom_func = require('./utils/custom_function');
var custom_func = new custom_func();
io.sockets.on('connection', frwsocket);
function frwsocket(frwstrike) {
bittrex.websockets.client(function () {
bittrex.websockets.listen(function (data, client) {
if(data.M === 'updateSummaryState') {
async.eachSeries(data.A, (value, key) => {
async.eachSeries(value.Deltas, (marketInfo, marketInfokey) => {
custom_func.updateDB(marketInfo.MarketName ,marketInfo).then(function(e) {
console.log(e);
if(e===0){
custom_func.saveTicker(marketInfo).then(function (e) {
console.log(e)
}).catch(function (err) {
console.log(err);
});
}else{
custom_func.getTickerSorted(marketInfo.MarketName).then(function (e) {
frwstrike.emit('stream', {
'value:': e
});
});
}
});
});
});
}
});
});
}
// function frwsocket(frwstrike) {
// var interval = setInterval(function () {
// custom_func.getTickerSorted().then(function (e) {
// // console.log(e);
// });
// }, 1000, "Hello.", "How are you?");
// }
//clearInterval(interval);