Closed SerialVelocity closed 7 years ago
function unpackLen(cb) {
stream.unpack('c', function(lenBytes) {
var byte1 = lenBytes[0];
if (byte1 & 0x80) {
stream.unpack('c', function(lenBytes) {
var byte2 = lenBytes[0];
len = byte1 | ( byte2 & 0x7f) << 7;
if (len & 0x80) {
stream.unpack('c', function(lenBytes) {
var byte3 = lenBytes[0];
len = len | ( byte3 & 0xff) << 14;
});
}
cb(len);
});
} else {
cb(byte1);
}
});
}
unpackLen(function(len) {
stream.get(len, function(pngData) {
rect.subEncoding = 'png'
rect.pngData = pngData;
cli.emit('rect', rect);
cb(rect);
});
});
successfully connected and authorised remote screen name: QEMU (clodo-mon-x86_64) width:1024 height: 768 buffer.js:262 throw new TypeError(kFromErrorMsg); ^
function unpackLen(cb) {
stream.unpack('c', function(lenBytes) {
var byte1 = lenBytes[0];
if (byte1 & 0x80) {
stream.unpack('c', function(lenBytes) {
var byte2 = lenBytes[0];
var len = byte1 | ( byte2 & 0x7f) << 7;
if (len & 0x80) {
stream.unpack('c', function(lenBytes) {
var byte3 = lenBytes[0];
len = len | ( byte3 & 0xff) << 14;
cb(len); // without this result is not 'returned' via callback in 3 bytes case
});
} else {
// without "else" it is 'returned' twice
cb(len);
}
});
} else {
cb(byte1);
}
});
}
@sidorares thanks, but it undefined wit you code. why we use unpack('c') and not capital C ?
with C i get lenght and it not undefined..
and i check and first rect is the png image =)
but next frmae i don't know' wireshark can't determine encoding. i think that qemu send another frame with this encoding.... but i can't get spec about it.
hm but it have garbage from beggining..
ah.. we need to skip from stream needed bytes that contains len =)
i'm stuck to get propet png (from beginning) i need to skip from stream 8 bytes =(
@sidorares do you have some thinks about this?
Hey,
Not sure if this is still maintained (works great for me!). Is it possible to add typescript bindings for this library? They need to be checked into https://github.com/DefinitelyTyped/DefinitelyTyped
Cheers, SerialVelocity