FileDocCategorySizeDatePackage
AsyncTransaction.javaAPI DocAndroid 1.5 API3137Wed May 06 22:42:46 BST 2009com.android.im.imps

AsyncTransaction

public abstract class AsyncTransaction extends ImpsTransaction

Fields Summary
private final AsyncCompletion
mCompletionCallback
private boolean
mCompletionNotified
protected final ImpsTransactionManager
mTransManager
Constructors Summary
AsyncTransaction(ImpsTransactionManager manager)

        this(manager, null);
    
AsyncTransaction(ImpsTransactionManager manager, AsyncCompletion completion)

        mTransManager = manager;
        mCompletionCallback = completion;
        manager.beginClientTransaction(this);
    
Methods Summary
protected voidnotifyAsyncCompletionError(com.android.im.engine.ImErrorInfo error)

        if (!mCompletionNotified) {
            mCompletionNotified = true;
            if (mCompletionCallback != null)
                mCompletionCallback.onError(error);
        }
    
protected voidnotifyAsyncCompletionSuccess()

        if (!mCompletionNotified) {
            mCompletionNotified = true;
            if (mCompletionCallback != null)
                mCompletionCallback.onComplete();
        }
    
final voidnotifyError(com.android.im.engine.ImErrorInfo error)
Notify that an error occurs in the transaction.

param
error the error

        notifyErrorResponse(new ImpsErrorInfo(error.getCode(), error.getDescription(), null));
    
protected voidnotifyErrorResponse(ImpsErrorInfo error)

        onResponseError(error);
        mTransManager.endClientTransaction(this);
        notifyAsyncCompletionError(error);
    
final voidnotifyResponse(Primitive response)
Notify that a response from the server has arrived.

param
response the response.

        response.setTransaction(this);
        ImpsErrorInfo error = ImpsUtils.checkResultError(response);
        if (error != null) {
            notifyErrorResponse(error);
        } else {
            notifySuccessResponse(response);
        }
    
protected voidnotifySuccessResponse(Primitive response)

        onResponseOk(response);
        mTransManager.endClientTransaction(this);
        notifyAsyncCompletionSuccess();
    
public abstract voidonResponseError(ImpsErrorInfo error)

public abstract voidonResponseOk(Primitive response)

public voidsendRequest(Primitive request)
Sends a request within this transaction.

param
request the request to send.

        sendPrimitive(request);