omnip620 / node-zookeeper-dubbo

A middleware helps node to communicate dubbo by using its default protocol, which is registered in zookeeper
300 stars 80 forks source link

你好,请教一下如下这句代码是如何执行的呢???代码socket读取数据逻辑是怎么样的呢?对数据大小有限制吗?? #75

Closed Erchoc closed 6 years ago

Erchoc commented 6 years ago

Socket.prototype.deSerialize = function(chunk) { const chunks = []; let bl = HEADER_LENGTH;

if (!chunks.length) { bl += chunk.readInt32BE(12); } chunks.push(chunk); const heap = Buffer.concat(chunks);

if (heap.length === bl) { decode(heap, (err, result) => { this.transmiting = false; this.heartBeatLock = false;

  err ? this.reject(err) : this.resolve(result);

  this.resolve = null;
  this.reject = null;
  this.cb(null, true);
});

} };

omnip620 commented 6 years ago

Fixed with a20cd528a07b32195233ac109d9d0d139c139915