diff --git a/src/adb/DeviceClient.ts b/src/adb/DeviceClient.ts index d571fd33..7aa354f8 100644 --- a/src/adb/DeviceClient.ts +++ b/src/adb/DeviceClient.ts @@ -161,7 +161,7 @@ export default class DeviceClient { * `jdwp:` * @returns true */ - public forward(local: string, remote: string): Bluebird { + public forward(local: string, remote: string): Bluebird { return this.connection().then((conn) => new ForwardCommand(conn).execute(this.serial, local, remote)); } diff --git a/src/adb/command/host-serial/forward.ts b/src/adb/command/host-serial/forward.ts index d230e0e0..24f22fcc 100644 --- a/src/adb/command/host-serial/forward.ts +++ b/src/adb/command/host-serial/forward.ts @@ -2,8 +2,8 @@ import Command from '../../command'; import Protocol from '../../protocol'; import Bluebird from 'bluebird'; -export default class ForwardCommand extends Command { - execute(serial: string, local: string, remote: string): Bluebird { +export default class ForwardCommand extends Command { + execute(serial: string, local: string, remote: string): Bluebird { this._send(`host-serial:${serial}:forward:${local};${remote}`); return this.parser.readAscii(4).then((reply) => { switch (reply) { @@ -11,7 +11,9 @@ export default class ForwardCommand extends Command { return this.parser.readAscii(4).then((reply) => { switch (reply) { case Protocol.OKAY: - return true; + return this.parser.readValue().then((buffer) => { + return Number(buffer.toString()); + }).catch(_ => 0); case Protocol.FAIL: return this.parser.readError(); default: