瀏覽代碼

Fix issue with fake-server

master
Nicolas Dextraze 3 年之前
父節點
當前提交
0a64b37b6f
共有 1 個文件被更改,包括 8 次插入6 次删除
  1. +8
    -6
      tools/fake-server.js

+ 8
- 6
tools/fake-server.js 查看文件

@@ -11,12 +11,14 @@ const server = net.createServer(function(socket) {
var recvBuf = new Buffer(0);
socket.on('data', function(buf) {
recvBuf = Buffer.concat([recvBuf, buf]);
const pkgData = tryReadPackage(recvBuf);
if (pkgData) {
handlePackage(pkgData, socket);
var oldBuf = recvBuf;
recvBuf = new Buffer(recvBuf.length - pkgData.size - 4);
oldBuf.copy(recvBuf, 0, 4 + pkgData.size);
let pkgData;
while(pkgData = tryReadPackage(recvBuf)) {
if (pkgData) {
handlePackage(pkgData, socket);
var oldBuf = recvBuf;
recvBuf = new Buffer(recvBuf.length - pkgData.size - 4);
oldBuf.copy(recvBuf, 0, 4 + pkgData.size);
}
}
});
socket.on('end', function() {


Loading…
取消
儲存