-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
199 lines (129 loc) · 4.39 KB
/
app.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
var request = require("request");
var _ = require('underscore');
var express = require('express');
var app = express(),
http = require('http'),
server = http.createServer(app),
io = require('socket.io').listen(server);
var OrderBookApi = require('./ApiLoader.js');
///////// Socket.io Configuration ////////////////////////////////
io.set('log level', 2); // Reduce socket logging
io.enable('browser client minification'); // send minified client
io.enable('browser client etag'); // apply etag caching logic based on version number
io.enable('browser client gzip'); // gzip the file
io.set('log level', 1); // reduce logging
// enable all transports (optional if you want flashsocket support, please note that some hosting
// providers do not allow you to create servers that listen on a port different than 80 or their
// default port)
io.set('transports', [
'websocket', 'xhr-polling', 'flashsocket', 'htmlfile', 'jsonp-polling'
]);
//////// App Express configuration ///////////////////////
app.configure(function() {
app.use(express.bodyParser());
app.set('view engine', 'html');
app.set('views', __dirname + '/web');
app.use(express.static(__dirname + '/web'));
app.use(express.logger());
app.use(express.favicon(__dirname + '/web/img/favicon.ico'));
app.use(app.router);
});
app.get('/', function(req, res) {
res.sendfile("web/index.html");
});
app.get('/pushtest', function(req, res) {
DataSender();
res.send('Ok!');
});
// Schedule Interval Config in milliseconds
var interval = {
small: 1200, //
medium: 1500, //
big: 5000 //
}
/// Schedulers I dont like this part
var scheduler1 = setInterval(function() {
OrderBookApi.LoadBitsampdata(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.medium);
var scheduler2 = setInterval(function() {
OrderBookApi.LoadBtceData(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
var scheduler3 = setInterval(function() {
OrderBookApi.LoadCoinsetter(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
var scheduler4 = setInterval(function() {
OrderBookApi.LoadKraken(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
var scheduler5 = setInterval(function() {
OrderBookApi.LoadBitfinex(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
/*
var scheduler6 = setInterval(function(){
OrderBookApi.LoadItBitData(function(err, bids, asks){
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
*/
var scheduler7 = setInterval(function() {
OrderBookApi.LoadANX(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
// var scheduler8 = setInterval(function(){
// OrderBookApi.LoadHitBtc(function(err, bids, asks){
// io.sockets.emit('echo', bids, asks);
// });
// }, interval.small);
var scheduler9 = setInterval(function() {
OrderBookApi.LoadOkcoin(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
var scheduler10 = setInterval(function() {
OrderBookApi.LoadCoinBase(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
var scheduler11 = setInterval(function() {
OrderBookApi.LoadLakeBTC(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
var scheduler12 = setInterval(function() {
OrderBookApi.LoadLiveCoins(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
var scheduler13 = setInterval(function() {
OrderBookApi.LoadGemini(function(err, bids, asks) {
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
/*
Cryptonit Still has problems
var scheduler11 = setInterval(function() {
OrderBookApi.LoadCryptonit(function(err, bids, asks){
io.sockets.emit('echo', bids, asks);
});
}, interval.small);
*/
// Bitex stopped API error
// var scheduler9 = setInterval(function(){
// OrderBookApi.Loadbitex(function(err, bids, asks){
// io.sockets.emit('echo', bids, asks);
// });
// }, interval.small);
//--
io.sockets.on('connection', function(socket) {});
//server.listen(80, '127.0.0.1');
server.listen(5000, '127.0.0.1'); // Production Server