Skip to content

Commit d483403

Browse files
yotamNimbleyotamN
authored andcommitted
Return port number or zero otherwise in forward command
1 parent 0a11b3b commit d483403

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/adb/DeviceClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export default class DeviceClient {
161161
* `jdwp:<process pid>`
162162
* @returns true
163163
*/
164-
public forward(local: string, remote: string): Bluebird<boolean> {
164+
public forward(local: string, remote: string): Bluebird<number> {
165165
return this.connection().then((conn) => new ForwardCommand(conn).execute(this.serial, local, remote));
166166
}
167167

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ import Command from '../../command';
22
import Protocol from '../../protocol';
33
import Bluebird from 'bluebird';
44

5-
export default class ForwardCommand extends Command<boolean> {
6-
execute(serial: string, local: string, remote: string): Bluebird<boolean> {
5+
export default class ForwardCommand extends Command<number> {
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)