Methods Summary |
---|
void | beginClientTransaction(AsyncTransaction tx)Originates an async transaction from the client.
synchronized(mClientTransactions) {
tx.setTransactionInfo(nextTransactionId(), mConnection);
mClientTransactions.put(tx.getId(), tx);
}
|
void | endClientTransaction(AsyncTransaction tx)Terminates a transaction which was originated from the client.
synchronized(mClientTransactions) {
mClientTransactions.remove(tx.getId());
}
|
private synchronized java.lang.String | nextTransactionId()Generates a new transaction ID.
if(mTransactionId >= 999) {
mTransactionId = 0;
}
return String.valueOf(++mTransactionId);
|
public void | notifyErrorResponse(java.lang.String transactionId, int code, java.lang.String info)TODO: This should not be called from the DataChannel thread.
AsyncTransaction tx;
synchronized(mClientTransactions) {
tx = mClientTransactions.get(transactionId);
}
if (tx != null) {
tx.notifyError(new ImErrorInfo(code, info));
} else {
ImpsLog.log("Ignoring possible server transaction error " + code + info);
}
|
public void | notifyIncomingPrimitive(Primitive primitive)Notifies the TransactionManager that a new primitive from the server has
arrived.
String transactionId = primitive.getTransactionID();
if (primitive.getTransactionMode() == TransactionMode.Response) {
AsyncTransaction tx;
synchronized(mClientTransactions) {
tx = mClientTransactions.get(transactionId);
}
// The transaction might has been terminated by the client,
// just ignore the incoming primitive in that case.
if (tx != null) {
tx.notifyResponse(primitive);
}
} else {
ServerTransaction serverTx = new ServerTransaction(transactionId,
mConnection, primitive);
ServerTransactionListener listener;
synchronized(mServerTransactionListeners) {
listener = mServerTransactionListeners.get(primitive.getType());
}
if (listener != null) {
listener.notifyServerTransaction(serverTx);
} else {
ImpsLog.log("Unhandled Server transaction: " + primitive.getType());
}
}
|
void | reassignTransactionId(Primitive p)
synchronized (mClientTransactions) {
AsyncTransaction tx = mClientTransactions.remove(p.getTransactionID());
if(tx != null) {
String newId = nextTransactionId();
tx.setTransactionInfo(newId, mConnection);
p.setTransactionId(newId);
mClientTransactions.put(newId, tx);
}
}
|
public void | setTransactionListener(java.lang.String type, ServerTransactionListener listener)Sets a ServerTransactionListener on this manager so that it will be
notified when a specified transaction has been initialized by the server.
synchronized(mServerTransactionListeners) {
if (listener == null) {
mServerTransactionListeners.remove(type);
} else {
mServerTransactionListeners.put(type, listener);
}
}
|