Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdbClient.ts #17

Open
lukemovement opened this issue Dec 25, 2021 · 0 comments
Open

AdbClient.ts #17

lukemovement opened this issue Dec 25, 2021 · 0 comments

Comments

@lukemovement
Copy link

Hey, thought this might be a bit simpler :)

  private messageChannel: MessageChannel;
  private messageQueue = new AsyncBlockingQueue<Message>();
  private openStreams: Set<Stream> = new Set();
  readonly keyStore = Array<CryptoKeyPair>();

  public static async create(options?: Partial<Options>) {
    options = Object.assign(
      {},
      {
        debug: true,
        useChecksum: false,
        dump: false,
        keySize: 2048,
      },
      options
    );

    const transport = await WebUsbTransport.open(options as Options);
    const adbClient = new AdbClient(transport, options as Options);
    await adbClient.connect();

    return adbClient;
  }

  /**
   * Creates a new AdbClient
   *
   * @param {Transport} transport the transport layer.
   */
  private constructor(
    readonly transport: Transport,
    readonly options: Options
  ) {
    this.messageChannel = new MessageChannel(transport, options, this);
  }

Usage

const client = await AdbClient.create();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant