public Message sendRequest(String operation, String[] body) throws IOException {
return sendRequest(operation, body, DEFAULT_TIMEOUT);
}
public Message sendRequest(String operation, String[] body, int timeout) throws IOException {
Message request = new Message(operation, body);
sendMessage(request);
Message reply = receiveMessage(request.getId(), timeout);
if (VoidMessage.OPERATION.equals(reply.getType())) {
return null;
} else if (ErrorMessage.OPERATION.equals(reply.getType())) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < reply.getBody().length; i++) {
buf.append(reply.getBody()[i]);
}
throw new RuntimeException(buf.toString());
}
return reply;