node-nats-streaming
Advanced tools
Comparing version 0.0.12 to 0.0.14
@@ -39,2 +39,6 @@ #!/usr/bin/env node | ||
stan.on('error', function(reason) { | ||
console.log(reason); | ||
}); | ||
function start() { | ||
@@ -41,0 +45,0 @@ stan.publish(subject, body, function(err, guid){ |
@@ -41,2 +41,6 @@ #!/usr/bin/env node | ||
stan.on('error', function(reason) { | ||
console.log(reason); | ||
}); | ||
function start() { | ||
@@ -43,0 +47,0 @@ var opts = stan.subscriptionOptions(); |
@@ -41,2 +41,6 @@ #!/usr/bin/env node | ||
stan.on('error', function(reason) { | ||
console.log(reason); | ||
}); | ||
function start() { | ||
@@ -43,0 +47,0 @@ var opts = stan.subscriptionOptions(); |
@@ -24,3 +24,3 @@ /*! | ||
*/ | ||
var VERSION = '0.0.12', | ||
var VERSION = '0.0.14', | ||
DEFAULT_PORT = 4222, | ||
@@ -257,2 +257,15 @@ DEFAULT_PRE = 'nats://localhost:', | ||
var cr = proto.ConnectResponse.deserializeBinary(new Buffer(msg, 'binary').toByteArray()); | ||
if (cr.getError() !== "") { | ||
// connect failed | ||
that.emit("error", cr.getError()); | ||
var nc = that.nc; | ||
delete that.nc; | ||
nc.flush(function(){ | ||
if (that.ncOwned) { | ||
nc.close(); | ||
that.emit('close'); | ||
} | ||
}); | ||
return; | ||
} | ||
that.pubPrefix = cr.getPubPrefix(); | ||
@@ -259,0 +272,0 @@ that.subRequests = cr.getSubRequests(); |
{ | ||
"name": "node-nats-streaming", | ||
"version": "0.0.12", | ||
"version": "0.0.14", | ||
"description": "Node.js client for NATS Streaming, a lightweight, high-performance cloud native messaging system", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -130,2 +130,23 @@ /* jshint node: true */ | ||
it('duplicate client id should fire error', function (done) { | ||
var wantTwo = 2; | ||
var id = nuid.next(); | ||
var stan = STAN.connect(cluster, id, PORT); | ||
stan.on('connect', function () { | ||
var stan2 = STAN.connect(cluster, id, PORT); | ||
stan2.on('error', function() { | ||
wantTwo--; | ||
if (wantTwo === 0) { | ||
done(); | ||
} | ||
}); | ||
stan2.on('close', function() { | ||
wantTwo--; | ||
if (wantTwo === 0) { | ||
done(); | ||
} | ||
}); | ||
}); | ||
}); | ||
it('should include the correct message in the callback', function (done) { | ||
@@ -132,0 +153,0 @@ var stan = STAN.connect(cluster, nuid.next(), PORT); |
165786
4762