mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-05 02:39:26 +02:00
refactor(adb): let backends deserialize packets by themselves for better optimization
This commit is contained in:
parent
38a76a2e0c
commit
8a521c8d93
11 changed files with 61 additions and 70 deletions
|
@ -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);
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue