2017-03-20 11:48:24 +01:00
|
|
|
package se.vidstige.jadb;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
2017-03-20 13:17:38 +01:00
|
|
|
import java.net.InetSocketAddress;
|
2017-03-20 11:48:24 +01:00
|
|
|
|
2018-08-02 11:28:03 +02:00
|
|
|
public class HostDisconnectFromRemoteTcpDevice extends HostConnectionCommand {
|
2017-03-20 12:48:09 +01:00
|
|
|
HostDisconnectFromRemoteTcpDevice(Transport transport) {
|
2018-08-02 11:28:03 +02:00
|
|
|
super(transport, new ResponseValidatorImp());
|
|
|
|
|
2017-03-20 11:48:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//Visible for testing
|
|
|
|
HostDisconnectFromRemoteTcpDevice(Transport transport, ResponseValidator responseValidator) {
|
2018-08-02 11:28:03 +02:00
|
|
|
super(transport, responseValidator);
|
2017-03-20 11:48:24 +01:00
|
|
|
}
|
|
|
|
|
2017-03-20 13:17:38 +01:00
|
|
|
InetSocketAddress disconnect(InetSocketAddress inetSocketAddress)
|
2017-03-20 11:48:24 +01:00
|
|
|
throws IOException, JadbException, ConnectionToRemoteDeviceException {
|
2018-08-02 11:28:03 +02:00
|
|
|
return executeHostCommand("disconnect", inetSocketAddress);
|
2017-03-20 11:48:24 +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_DISCONNECTED = "disconnected";
|
|
|
|
private static final String ALREADY_DISCONNECTED = "error: no such device";
|
2017-03-20 11:48:24 +01:00
|
|
|
|
2017-03-20 12:48:09 +01:00
|
|
|
ResponseValidatorImp() {
|
2018-08-02 11:28:03 +02:00
|
|
|
super(SUCCESSFULLY_DISCONNECTED, ALREADY_DISCONNECTED);
|
2017-03-20 11:48:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|