Fix issue with fake-server
This commit is contained in:
parent
3421d41068
commit
0a64b37b6f
|
@ -11,13 +11,15 @@ const server = net.createServer(function(socket) {
|
||||||
var recvBuf = new Buffer(0);
|
var recvBuf = new Buffer(0);
|
||||||
socket.on('data', function(buf) {
|
socket.on('data', function(buf) {
|
||||||
recvBuf = Buffer.concat([recvBuf, buf]);
|
recvBuf = Buffer.concat([recvBuf, buf]);
|
||||||
const pkgData = tryReadPackage(recvBuf);
|
let pkgData;
|
||||||
|
while(pkgData = tryReadPackage(recvBuf)) {
|
||||||
if (pkgData) {
|
if (pkgData) {
|
||||||
handlePackage(pkgData, socket);
|
handlePackage(pkgData, socket);
|
||||||
var oldBuf = recvBuf;
|
var oldBuf = recvBuf;
|
||||||
recvBuf = new Buffer(recvBuf.length - pkgData.size - 4);
|
recvBuf = new Buffer(recvBuf.length - pkgData.size - 4);
|
||||||
oldBuf.copy(recvBuf, 0, 4 + pkgData.size);
|
oldBuf.copy(recvBuf, 0, 4 + pkgData.size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
socket.on('end', function() {
|
socket.on('end', function() {
|
||||||
console.log('Connection closed');
|
console.log('Connection closed');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user