-
- All Implemented Interfaces:
public class TransactionIDThis class encapsulates a STUN transaction ID. It is useful for storing transaction IDs in collection objects as it implements the equals method. It also provides a utility for creating unique transaction IDs.
-
-
Field Summary
Fields Modifier and Type Field Description public final static intRFC5389_TRANSACTION_ID_LENGTHpublic final static intRFC3489_TRANSACTION_ID_LENGTHprivate ObjectapplicationData
-
Method Summary
Modifier and Type Method Description ObjectgetApplicationData()Returns whatever applicationData was previously stored in this ID. voidsetApplicationData(Object applicationData)Stores applicationData in this ID so that we can refer back to it if we ever need to at a later stage (e.g. static TransactionIDcreateNewTransactionID()Creates a transaction id object. static TransactionIDcreateNewRFC3489TransactionID()Creates a RFC3489 transaction id object. static TransactionIDcreateTransactionID(StunStack stunStack, Array<byte> transactionID)Returns a TransactionID instance for the specified id. Array<byte>getBytes()Returns the transaction id byte array (length 12 or 16 if RFC3489 compatible). booleanisRFC3489Compatible()If the transaction is compatible with RFC3489 (16 bytes). booleanequals(Object obj)Compares two TransactionID objects. booleanequals(Array<byte> targetID)Compares the specified byte array with this transaction id. inthashCode()Returns the first four bytes of the transactionID to ensure proper retrieval from hashtables. StringtoString()Returns a string representation of the ID static StringtoString(Array<byte> transactionID)Returns a string representation of the ID -
-
Method Detail
-
getApplicationData
Object getApplicationData()
Returns whatever applicationData was previously stored in this ID.
-
setApplicationData
void setApplicationData(Object applicationData)
Stores applicationData in this ID so that we can refer back to it if we ever need to at a later stage (e.g. when receiving a response to a StunClientTransaction).
- Parameters:
applicationData- a reference to the Object that the application would like to correlate to the transaction represented by this ID.
-
createNewTransactionID
static TransactionID createNewTransactionID()
Creates a transaction id object.The transaction id itself is generated using the following algorithm: The first 6 bytes of the id are given the value of System.currentTimeMillis(). Putting the right most bits first so that we get a more optimized equals() method.
-
createNewRFC3489TransactionID
static TransactionID createNewRFC3489TransactionID()
Creates a RFC3489 transaction id object.The transaction id itself is generated using the following algorithm: The first 8 bytes of the id are given the value of System.currentTimeMillis(). Putting the right most bits first so that we get a more optimized equals() method.
-
createTransactionID
static TransactionID createTransactionID(StunStack stunStack, Array<byte> transactionID)
Returns a TransactionID instance for the specified id. If transactionID is the ID of a client or a server transaction already known to the stack, then this method would return a reference to that transaction's instance so that we could use it to for storing application data.
- Parameters:
stunStack- the StunStack in the context of which the request to create a TransactionID is being madetransactionID- the value of the ID.
-
getBytes
Array<byte> getBytes()
Returns the transaction id byte array (length 12 or 16 if RFC3489 compatible).
-
isRFC3489Compatible
boolean isRFC3489Compatible()
If the transaction is compatible with RFC3489 (16 bytes).
-
equals
boolean equals(Object obj)
Compares two TransactionID objects.
- Parameters:
obj- the object to compare with.
-
equals
boolean equals(Array<byte> targetID)
Compares the specified byte array with this transaction id.
- Parameters:
targetID- the id to compare with ours.
-
hashCode
int hashCode()
Returns the first four bytes of the transactionID to ensure proper retrieval from hashtables.
-
-
-
-