Comparing version 4.1.1 to 4.1.2
@@ -258,3 +258,5 @@ /** | ||
}) | ||
.forEach(fromLink.sendEdit.bind(fromLink)) | ||
.forEach(function(edit) { | ||
fromLink.sendEdit(edit) | ||
}) | ||
}.bind(this)) | ||
@@ -261,0 +263,0 @@ |
@@ -39,2 +39,3 @@ /** | ||
this.queue | ||
this.linkBuffer = '' | ||
@@ -88,3 +89,3 @@ Duplex.call(this, {allowHalfOpen: false, objectMode: true}) | ||
clearTimeout(edit.timeout) | ||
cb && cb.apply(null, arguments) | ||
if (cb) cb.apply(null, arguments) | ||
} | ||
@@ -96,3 +97,3 @@ msg[1] = edit.pack() | ||
debug('->', data) | ||
this.push(data) | ||
this.push(data+'\n') | ||
}.bind(this)) | ||
@@ -102,15 +103,15 @@ } | ||
Link.prototype.sendUnauthenticated = function() { | ||
this.push(JSON.stringify(['unauthenticated'])) | ||
this.push(JSON.stringify(['unauthenticated'])+'\n') | ||
} | ||
Link.prototype.sendAuthenticate = function() { | ||
this.push(JSON.stringify(['authenticate', this.credentials])) | ||
this.push(JSON.stringify(['authenticate', this.credentials])+'\n') | ||
} | ||
Link.prototype.sendAuthenticated = function(status) { | ||
this.push(JSON.stringify(['authenticated', status])) | ||
this.push(JSON.stringify(['authenticated', status])+'\n') | ||
} | ||
Link.prototype.sendUnauthorized = function() { | ||
this.push(JSON.stringify(['unauthorized'])) | ||
this.push(JSON.stringify(['unauthorized'])+'\n') | ||
} | ||
@@ -161,5 +162,23 @@ | ||
Link.prototype._write = function(buf, enc, cb) { | ||
debug('<- _write:', buf.toString()) | ||
var args = JSON.parse(buf.toString()) | ||
this.linkBuffer += buf.toString() | ||
var idx = this.linkBuffer.indexOf('\n') | ||
if (idx === -1) return cb() | ||
var msgs = [] | ||
while (idx !== -1) { | ||
msgs.push(this.linkBuffer.substr(0, idx)) | ||
this.linkBuffer = this.linkBuffer.substr(idx+1) | ||
idx = this.linkBuffer.indexOf('\n') | ||
} | ||
iterate.apply(this) | ||
function iterate(er) { | ||
if (er) return cb(er) | ||
if (!msgs.length) return cb() | ||
this.onwrite(msgs.shift(), iterate.bind(this)) | ||
} | ||
} | ||
Link.prototype.onwrite = function(data, cb) { | ||
debug('<- _write:', data) | ||
var args = JSON.parse(data) | ||
// ['authenticate', Mixed] | ||
@@ -166,0 +185,0 @@ if(args[0] === 'authenticate') { |
{ | ||
"name": "gulf", | ||
"version": "4.1.1", | ||
"version": "4.1.2", | ||
"description": "transport-agnostic operational transformation control layer", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
530530
17
13918
4