mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-06 03:50:18 +02:00
feat: correctly close adb connection
This commit is contained in:
parent
be4dfcd614
commit
7a7f38b3b5
14 changed files with 354 additions and 331 deletions
|
@ -9,7 +9,7 @@ export const AdbSyncDataResponse =
|
|||
.uint8Array('data', { lengthField: 'dataLength' })
|
||||
.extra({ id: AdbSyncResponseId.Data as const });
|
||||
|
||||
const ResponseTypes = {
|
||||
const RESPONSE_TYPES = {
|
||||
[AdbSyncResponseId.Data]: AdbSyncDataResponse,
|
||||
[AdbSyncResponseId.Done]: new AdbSyncDoneResponse(AdbSyncDataResponse.size),
|
||||
};
|
||||
|
@ -24,7 +24,7 @@ export function adbSyncPull(
|
|||
await adbSyncWriteRequest(writer, AdbSyncRequestId.Receive, path);
|
||||
},
|
||||
async pull(controller) {
|
||||
const response = await adbSyncReadResponse(stream, ResponseTypes);
|
||||
const response = await adbSyncReadResponse(stream, RESPONSE_TYPES);
|
||||
switch (response.id) {
|
||||
case AdbSyncResponseId.Data:
|
||||
controller.enqueue(response.data!);
|
||||
|
@ -35,7 +35,10 @@ export function adbSyncPull(
|
|||
default:
|
||||
throw new Error('Unexpected response id');
|
||||
}
|
||||
}
|
||||
},
|
||||
cancel() {
|
||||
throw new Error(`Sync commands don't support cancel.`);
|
||||
},
|
||||
}, {
|
||||
highWaterMark: 16 * 1024,
|
||||
size(chunk) { return chunk.byteLength; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue