Altered the buffering code within feedback handler so that a partial response when data has already buffered will add to the buffer.

This commit is contained in:
Andrew Naylor 2010-10-08 17:46:52 +01:00
Родитель 1951c6673e
Коммит a23f50a0a1
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -272,10 +272,15 @@ var Feedback = function (optionArgs) {
} }
var processData = function(data) { var processData = function(data) {
// Need to parse this data in correct lengths;
var pos = 0; var pos = 0;
// If there is some buffered data read read the remainder and process this first.
if(readLength > 0) { if(readLength > 0) {
data.copy(readBuffer, readLength, 0, 38-readLength); if(data.length < (responsePacketLength - readLength)) {
data.copy(readBuffer, readLength, 0);
readLength += data.length;
return;
}
data.copy(readBuffer, readLength, 0, responsePacketLength-readLength);
decodeResponse(readBuffer, 0); decodeResponse(readBuffer, 0);
pos = responsePacketLength-readLength; pos = responsePacketLength-readLength;
readLength = 0; readLength = 0;