-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further changes as part of #15. Also changed code for how client work…
…s to make it more reusable
- Loading branch information
Gerard Moroney
committed
Jan 4, 2018
1 parent
70cfbeb
commit d45dc8a
Showing
2 changed files
with
20 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters