private void waitForResponse(TProtocol in, int sequenceId)
throws TException
{
TMessage message = in.readMessageBegin();
if (message.type == EXCEPTION) {
TApplicationException exception = TApplicationException.read(in);
in.readMessageEnd();
throw exception;
}
if (message.type != REPLY) {
throw new TApplicationException(INVALID_MESSAGE_TYPE,
"Received invalid message type " + message.type + " from server");
}
if (!message.name.equals(this.name)) {
throw new TApplicationException(WRONG_METHOD_NAME,
"Wrong method name in reply: expected " + this.name + " but received " + message.name);
}
if (message.seqid != sequenceId) {
throw new TApplicationException(BAD_SEQUENCE_ID, name + " failed: out of sequence response");
}
}