Comparing version 1.0.0 to 1.1.0
@@ -67,2 +67,3 @@ 'use strict'; | ||
nats.close(); | ||
process.exit(0); | ||
}); | ||
@@ -98,2 +99,3 @@ rl.on('line', function (line) { | ||
}); | ||
nats.once('disconnect', done); | ||
}, function () { | ||
@@ -148,4 +150,28 @@ nats.unsubscribe(sid); | ||
var nats = _nats2.default.connect(_commander2.default.server); | ||
function ping() { | ||
if (!nats || !nats.pongs) return; | ||
nats.sendCommand('PING\r\n'); | ||
nats.pongs.push(null); | ||
} | ||
setInterval(function () { | ||
if (nats && nats.pongs && nats.pongs.length > 5) return nats.stream.end(); | ||
ping(); | ||
}, 1000); | ||
function attachDisconnectHandler() { | ||
nats.once('disconnect', function () { | ||
rl.pause(); | ||
rl.clearLine(process.stdout, 0); | ||
_util2.default.warn("Disconnected from server, attempting reconnect..."); | ||
nats.once('reconnect', function () { | ||
rl.resume(); | ||
rl.prompt(); | ||
attachDisconnectHandler(); | ||
}); | ||
}); | ||
} | ||
nats.on('close', function () { | ||
process.exit(0); | ||
_util2.default.error("Connection was closed"); | ||
rl.close(); | ||
}); | ||
@@ -159,2 +185,3 @@ nats.on('error', function (e) { | ||
_util2.default.info("Connected to server " + nats.url.href); | ||
attachDisconnectHandler(); | ||
rl.setPrompt('> '); | ||
@@ -161,0 +188,0 @@ rl.prompt(); |
{ | ||
"name": "nats-repl", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A simple REPL client for NATS", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6218
7
215