Skip to content

Commit

Permalink
Return port number or zero otherwise in forward command
Browse files Browse the repository at this point in the history
  • Loading branch information
yotamNimble authored and yotamN committed Jun 13, 2023
1 parent 0a11b3b commit d483403
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/adb/DeviceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class DeviceClient {
* `jdwp:<process pid>`
* @returns true
*/
public forward(local: string, remote: string): Bluebird<boolean> {
public forward(local: string, remote: string): Bluebird<number> {
return this.connection().then((conn) => new ForwardCommand(conn).execute(this.serial, local, remote));
}

Expand Down
8 changes: 5 additions & 3 deletions src/adb/command/host-serial/forward.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ import Command from '../../command';
import Protocol from '../../protocol';
import Bluebird from 'bluebird';

export default class ForwardCommand extends Command<boolean> {
execute(serial: string, local: string, remote: string): Bluebird<boolean> {
export default class ForwardCommand extends Command<number> {
execute(serial: string, local: string, remote: string): Bluebird<number> {
this._send(`host-serial:${serial}:forward:${local};${remote}`);
return this.parser.readAscii(4).then((reply) => {
switch (reply) {
case Protocol.OKAY:
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:
Expand Down

0 comments on commit d483403

Please sign in to comment.