insight-cli
Advanced tools
Comparing version 0.4.3 to 0.4.4
var StreamClient = require('..').StreamClient; | ||
var scl = new StreamClient(); | ||
scl.console() | ||
scl.console(0xffffff) | ||
@@ -5,0 +5,0 @@ setTimeout(function(){ |
@@ -9,15 +9,31 @@ 'use strict' | ||
InsightStreamClient.prototype.console = function(){ | ||
this.socket.on('tx', function(data) { | ||
console.log("New transaction received: " + data.txid) | ||
console.log(data) | ||
}) | ||
this.socket.on('block', function(data) { | ||
console.log("New block received: " + data.hash) | ||
console.log(data) | ||
}) | ||
this.socket.on('status', function(data) { | ||
console.log("New status recieved:") | ||
console.log(data) | ||
}) | ||
InsightStreamClient.prototype.console = function(flags){ | ||
var tbl = { | ||
tx : (flags >>> 0) & 0xff, | ||
block : (flags >>> 8) & 0xff, | ||
status : (flags >>> 16) & 0xff, | ||
txdetail : (flags >>> 24) & 0xff, | ||
} | ||
if(tbl.tx){ | ||
this.socket.on('tx', function(data) { | ||
console.log("New transaction received: " + data.txid) | ||
if(tbl.txdetail){ | ||
console.log(data) | ||
} | ||
}) | ||
} | ||
if(tbl.block){ | ||
this.socket.on('block', function(blockhash) { | ||
console.log("New block received: " + blockhash) | ||
}) | ||
} | ||
if(tbl.status){ | ||
this.socket.on('status', function(data) { | ||
console.log("New status recieved:") | ||
console.log(data) | ||
}) | ||
} | ||
} | ||
@@ -45,2 +61,5 @@ | ||
var connect = function(host){ | ||
var elog = function(str){ | ||
console.error(str); | ||
} | ||
var socket = io.connect(host, {reconnectionAttempts:10}); | ||
@@ -51,12 +70,12 @@ socket.on('connect', function() { | ||
socket.on('disconnect', function() { | ||
console.log('disconnect'); | ||
elog('disconnect') | ||
}) | ||
socket.on('reconnecting', function(num){ | ||
console.log('reconnecting'); | ||
elog('reconnecting'); | ||
}) | ||
socket.on('reconnect', function(num){ | ||
console.log('reconnect'); | ||
elog('reconnect'); | ||
}) | ||
socket.on('reconnect_failed', function(num){ | ||
console.log('reconnect_failed'); | ||
elog('reconnect_failed'); | ||
}) | ||
@@ -63,0 +82,0 @@ return socket; |
{ | ||
"author": "Yuki Akiyama", | ||
"name": "insight-cli", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
21532
304