Skip to content

Commit 66fe5c9

Browse files
committed
Return port number or zero otherwise in forward command
1 parent 0a11b3b commit 66fe5c9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/adb/command/host-serial/forward.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ import Protocol from '../../protocol';
33
import Bluebird from 'bluebird';
44

55
export default class ForwardCommand extends Command<boolean> {
6-
execute(serial: string, local: string, remote: string): Bluebird<boolean> {
6+
execute(serial: string, local: string, remote: string): Bluebird<number> {
77
this._send(`host-serial:${serial}:forward:${local};${remote}`);
88
return this.parser.readAscii(4).then((reply) => {
99
switch (reply) {
1010
case Protocol.OKAY:
1111
return this.parser.readAscii(4).then((reply) => {
1212
switch (reply) {
1313
case Protocol.OKAY:
14-
return true;
14+
return this.parser.readValue().then((buffer) => {
15+
return Number(buffer.toString());
16+
}).catch(_ => 0);
1517
case Protocol.FAIL:
1618
return this.parser.readError();
1719
default:

0 commit comments

Comments
 (0)