limitd-client
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -49,6 +49,6 @@ var url = require('url'); | ||
decoded = ResponseMessage.decode(chunk); | ||
callback(null, decoded); | ||
} catch(err) { | ||
callback(err); | ||
return callback(err); | ||
} | ||
callback(null, decoded); | ||
})) | ||
@@ -55,0 +55,0 @@ .on('data', function (response) { |
{ | ||
"name": "limitd-client", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "limitd client for node.js", | ||
@@ -19,3 +19,2 @@ "main": "index.js", | ||
"reconnect-net": "0.0.0", | ||
"remove": "~0.1.5", | ||
"through2": "~2.0.0" | ||
@@ -26,3 +25,3 @@ }, | ||
"mocha": "~2.2.4", | ||
"through": "~2.3.7" | ||
"through": "~2.3.8" | ||
}, | ||
@@ -29,0 +28,0 @@ "homepage": "https://github.com/limitd/node-client", |
@@ -33,3 +33,2 @@ var LimitdClient = require('../'); | ||
assert.isString(request.id); | ||
assert.equal(request.method, protocol.Request.Method[method.toUpperCase()]); | ||
@@ -36,0 +35,0 @@ assert.equal(request.type, 'ip'); |
var net = require('net'); | ||
var util = require('util'); | ||
var through = require('through'); | ||
var lps = require('length-prefixed-stream'); | ||
var through2 = require('through2'); | ||
var EventEmitter = require('events').EventEmitter; | ||
var pbStream = require('pb-stream'); | ||
var protocol = require('../lib/protocol'); | ||
@@ -16,4 +16,4 @@ | ||
var decoder = pbStream.decoder(protocol.Request); | ||
var encoder = pbStream.encoder(protocol.Response); | ||
// var decoder = pbStream.decoder(protocol.Request); | ||
// var encoder = pbStream.encoder(protocol.Response); | ||
@@ -23,13 +23,35 @@ this._server = net.createServer(function (socket) { | ||
socket.pipe(decoder) | ||
.pipe(through(function (request) { | ||
socket.pipe(lps.decode()) | ||
.pipe(through2.obj(function (chunk, enc, callback) { | ||
var decoded; | ||
try { | ||
decoded = protocol.Request.decode(chunk); | ||
} catch(err) { | ||
console.log(err); | ||
return callback(err); | ||
} | ||
callback(null, decoded); | ||
})) | ||
.pipe(through2.obj(function (request, enc, callback) { | ||
var stream = this; | ||
var replier = function (response) { | ||
stream.queue(response); | ||
stream.push(response); | ||
}; | ||
self.emit('request', request, replier); | ||
callback(); | ||
})) | ||
.pipe(encoder) | ||
.pipe(through2.obj(function (response, enc, callback) { | ||
var encoded; | ||
try { | ||
encoded = response.encodeDelimited().toBuffer(); | ||
} catch(err) { | ||
return callback(err); | ||
} | ||
callback(null, encoded); | ||
})) | ||
.pipe(socket); | ||
@@ -36,0 +58,0 @@ |
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
26292
8
476
- Removedremove@~0.1.5
- Removedchainsaw@0.0.9(transitive)
- Removedhashish@0.0.4(transitive)
- Removedremove@0.1.5(transitive)
- Removedseq@0.3.5(transitive)
- Removedtraverse@0.3.9(transitive)