long revent = 0;
log.info("Chatting");
for (int i = 0; i < TestTPConversation.interationCount; i++) {
byte[] bytes = ("hi" + i).getBytes();
X_OCTET sendbuf = (X_OCTET) svcinfo.getConnection().tpalloc(
"X_OCTET", null, bytes.length);
sendbuf.setByteArray(bytes);
// btlogger((char*) "testTPConversation_service:%s:",
// sendbuf);
int result = svcinfo.getSession().tpsend(sendbuf,
Connection.TPRECVONLY);
if (result != -1) {
try {
svcinfo.getSession().tprecv(0);
fail = true;
break;
} catch (ResponseException e) {
if (e.getEvent() == Connection.TPEV_SENDONLY) {
Buffer rcvbuf = e.getReceived();
if (TestTPConversation.strcmp("yo" + i, rcvbuf) != 0) {
fail = true;
break;
}
} else {
fail = true;
break;
}
} catch (ConnectionException e) {
fail = true;
break;
}
} else {
fail = true;
break;
}
}
log.info("Chatted");
}
if (fail) {
return new Response((short) Connection.TPESVCFAIL, 0, null, 0);
} else {
byte[] bytes = ("hi" + TestTPConversation.interationCount)
.getBytes();
X_OCTET sendbuf = (X_OCTET) svcinfo.getConnection().tpalloc(
"X_OCTET", null, bytes.length);
sendbuf.setByteArray(bytes);
return new Response(Connection.TPSUCCESS, 0, sendbuf, 0);
}
}