Skip to content

Commit

Permalink
Further changes as part of #15. Also changed code for how client work…
Browse files Browse the repository at this point in the history
…s to make it more reusable
  • Loading branch information
Gerard Moroney committed Jan 4, 2018
1 parent 70cfbeb commit d45dc8a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
27 changes: 20 additions & 7 deletions src/client_BINANCE-ZRXETH.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
/*jshint esversion: 6 */

// Include packages
var sys = require('util');

// Connect to Redis
var redis = require('redis');
var client = redis.createClient('6379','127.0.0.1');
global.client = redis.createClient('6379','127.0.0.1');
client.on('connect', function() {
console.log('Connected to Redis Server');
});

client.subscribe("BINANCE:ZRXETH");
// Subscribe to Redis channel and output values
function clientSubscribe(conn) {
client.subscribe(conn.exchange:conn.symbol);
client.on("message", function(channel, message) {
const msg = JSON.parse(message);
console.log(channel,msg.tr_id,msg.tr_side);
});
}

client.on("message", function(channel, message) {
const msg = JSON.parse(message);
//console.log("Message '" + message + "' on channel '" + channel + "' arrived!")
console.log(channel,msg.tr_id,msg.tr_side);
});
// Main function
function main () {
var connection = [];
connection.exchange = 'BINANCE';
connection.symbol = 'ZRXETH';
clientSubscribe();
}

// Call main function
main();
1 change: 0 additions & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var config = require('../config/default.json');

// Create Redis client connection
global.client = redis.createClient(config.redis.port,config.redis.host);

client.on('connect', function() {
console.log('Connected to Redis Server');
});
Expand Down

0 comments on commit d45dc8a

Please sign in to comment.