2017-03-17 17:48:13 +01:00
|
|
|
package se.vidstige.jadb;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
2017-03-20 13:17:38 +01:00
|
|
|
import java.net.InetSocketAddress;
|
2017-03-17 17:48:13 +01:00
|
|
|
|
2018-08-02 11:28:03 +02:00
|
|
|
class HostConnectToRemoteTcpDevice extends HostConnectionCommand {
|
2017-03-20 11:48:24 +01:00
|
|
|
HostConnectToRemoteTcpDevice(Transport transport) {
|
2018-08-02 11:28:03 +02:00
|
|
|
super(transport, new ResponseValidatorImp());
|
2017-03-20 11:18:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Visible for testing
|
|
|
|
HostConnectToRemoteTcpDevice(Transport transport, ResponseValidator responseValidator) {
|
2018-08-02 11:28:03 +02:00
|
|
|
super(transport, responseValidator);
|
2017-03-17 17:48:13 +01:00
|
|
|
}
|
|
|
|
|
2017-03-20 13:17:38 +01:00
|
|
|
InetSocketAddress connect(InetSocketAddress inetSocketAddress)
|
2017-03-17 17:48:13 +01:00
|
|
|
throws IOException, JadbException, ConnectionToRemoteDeviceException {
|
2018-08-02 11:28:03 +02:00
|
|
|
return executeHostCommand("connect", inetSocketAddress);
|
2017-03-17 17:48:13 +01:00
|
|
|
}
|
|
|
|
|
2018-08-02 11:28:03 +02:00
|
|
|
static final class ResponseValidatorImp extends ResponseValidatorBase {
|
2018-07-30 11:54:56 +02:00
|
|
|
private static final String SUCCESSFULLY_CONNECTED = "connected to";
|
|
|
|
private static final String ALREADY_CONNECTED = "already connected to";
|
2017-03-17 17:48:13 +01:00
|
|
|
|
2017-03-20 11:48:24 +01:00
|
|
|
ResponseValidatorImp() {
|
2018-08-02 11:28:03 +02:00
|
|
|
super(SUCCESSFULLY_CONNECTED, ALREADY_CONNECTED);
|
2017-03-17 17:48:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|