}
clearLock(clazz);
}
public void sendText(String message) {
ContextKey ck = getContextKey();
switch (clientState.getCurrentState()) {
case INIT:
// Allow the user to indicate bit-length
send(new PublicKeyRequest(ck.getA(), ck.getB(),
ConfigLoader.loadInt("key", "ELGAMAL_BITLENGTH")));
waitForResponse(PublicKeyResponse.class);
sendText(message);
break;
case PUBLIC_KEY_RECEIVED:
// Allow user to indicate shared key
send(new ExchSharedKeyRequest(ck.getA(), ck.getB(), ConfigLoader
.load("key", "AES_KEY").getBytes()));
waitForResponse(ExchSharedKeyResponse.class);
sendText(message);
break;
case SHARED_KEY_EXCHANGED:
send(new SendTextRequest(ck.getA(), ck.getB(), message));
waitForResponse(SendTextResponse.class);
// Check self state to determine whether need to resend
if (!(clientState.getCurrentState() == CState.SHARED_KEY_EXCHANGED)) {
// Error encountered, Resend
sendText(message);