refactor(adb): let backends deserialize packets by themselves for better optimization

This commit is contained in:
Simon Chan 2022-04-03 12:49:38 +08:00
parent 38a76a2e0c
commit 8a521c8d93
No known key found for this signature in database
GPG key ID: A8B69F750B9BCEDD
11 changed files with 61 additions and 70 deletions

View file

@ -158,25 +158,17 @@ function _Connect(): JSX.Element | null {
try {
setConnecting(true);
const dataStreamPair = await selectedBackend.connect();
const packetStreamPair = Adb.createConnection({
readable: dataStreamPair.readable
.pipeThrough(new InspectStream(chunk => {
byteInAcc.current += chunk.byteLength;
})),
writable: dataStreamPair.writable,
});
const streams = await selectedBackend.connect();
// Use `TransformStream` to intercept packets and log them
const readable = packetStreamPair.readable
const readable = streams.readable
.pipeThrough(
new InspectStream(packet => {
globalState.appendLog('Incoming', packet);
})
);
const writable = pipeFrom(
packetStreamPair.writable,
streams.writable,
new InspectStream(packet => {
globalState.appendLog('Outgoing', packet);
})