mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 18:29:23 +02:00
refactor(adb): simplify reading sync responses
This commit is contained in:
parent
c9000c5beb
commit
1486eed3cf
18 changed files with 164 additions and 183 deletions
|
@ -168,7 +168,12 @@ export class AdbPacketDispatcher implements Closeable {
|
|||
// the device may also respond with two `CLSE` packets.
|
||||
}
|
||||
|
||||
public addIncomingSocketHandler(handler: AdbIncomingSocketHandler): RemoveEventListener {
|
||||
/**
|
||||
* Add a handler for incoming socket.
|
||||
* @param handler A function to call with new incoming sockets. It must return `true` if it accepts the socket.
|
||||
* @returns A function to remove the handler.
|
||||
*/
|
||||
public onIncomingSocket(handler: AdbIncomingSocketHandler): RemoveEventListener {
|
||||
this._incomingSocketHandlers.add(handler);
|
||||
const remove = () => {
|
||||
this._incomingSocketHandlers.delete(handler);
|
||||
|
@ -178,7 +183,7 @@ export class AdbPacketDispatcher implements Closeable {
|
|||
}
|
||||
|
||||
private async handleOpen(packet: AdbPacketData) {
|
||||
// AsyncOperationManager doesn't support get and skip an ID
|
||||
// `AsyncOperationManager` doesn't support skipping IDs
|
||||
// Use `add` + `resolve` to simulate this behavior
|
||||
const [localId] = this.initializers.add<number>();
|
||||
this.initializers.resolve(localId, undefined);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue