UNPKG

@u4/adbkit

Version:

A Typescript client for the Android Debug Bridge.

29 lines 1.02 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const command_1 = __importDefault(require("../../command")); // Possible replies: // "unable to connect to 192.168.2.2:5555" // "connected to 192.168.2.2:5555" // "already connected to 192.168.2.2:5555" const RE_OK = /connected to|already connected/; class HostConnectCommand extends command_1.default { async execute(host, port) { await this._send(`host:connect:${host}:${port}`); await this.readOKAY(); const value = await this.parser.readValue('utf8'); if (RE_OK.test(value)) { if (value.includes("already connected")) return false; else return true; } else { throw new Error(value); } } } exports.default = HostConnectCommand; //# sourceMappingURL=HostConnectCommand.js.map