Small refactoring to make command definitions even smaller

This commit is contained in:
Jonathan Leibiusky
2010-06-11 21:41:46 -03:00
parent 55f640c8ff
commit 4ccb12cd75
4 changed files with 50 additions and 45 deletions

View File

@@ -7,19 +7,24 @@ import java.net.Socket;
import java.net.UnknownHostException;
public class Client {
protected String host;
protected int port = Protocol.DEFAULT_PORT;
protected Socket socket;
protected boolean connected = false;
protected Protocol protocol = new Protocol();
protected OutputStream outputStream;
protected InputStream inputStream;
private String host;
private int port = Protocol.DEFAULT_PORT;
private Socket socket;
private boolean connected = false;
private Protocol protocol = new Protocol();
private OutputStream outputStream;
private InputStream inputStream;
public Client(String host) {
super();
this.host = host;
}
protected Client sendCommand(String name, String... args) {
protocol.sendCommand(outputStream, name, args);
return this;
}
public Client(String host, int port) {
super();
this.host = host;
@@ -69,4 +74,12 @@ public class Client {
return connected;
}
protected String getSingleLineReply() {
return protocol.getSingleLineReply(inputStream);
}
public String getBulkReply() {
return protocol.getBulkReply(inputStream);
}
}