Package com.iizix.server.client
Class ClientTransactionProcessor
- java.lang.Object
- com.iizix.server.client.ClientTransactionProcessor
- All Implemented Interfaces:
IClientTransactionProcessor
,ITransactionCreator
,ITransactionProcessor
,IRootPropTransactionSender
public class ClientTransactionProcessor extends java.lang.Object implements IClientTransactionProcessor, IRootPropTransactionSender
The TransactionProcessor contains all the code required to process transactions with the application being run for a single client reconnectable connection. If parallel client sessions is enabled or allowed, a single AppSessionGyro is shared.- Author:
- Christopher Mindus
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendPublicKey(SendTransaction trans)
Appends the server public key for the Diffie-Hellman key exchange with the client.void
closeClient(java.lang.String msg)
Sends an HTML message to be displayed on the client that will immediately close the connection.SendTransaction
createTransaction()
Creates a transaction with the configured write cache.java.lang.String
getClientContextMenuReference(UIContextMenu contextMenu)
Gets the reference to use for a context menu.ClientParams
getClientParams()
Gets the client parameters.ClientProps
getClientProps()
Gets the client properties.int
getLockSerial()
Returns the lock serial number.boolean
isConnected()
Verifies that the connection is established and not paused, reconnecting, etc.void
onConnection(SessionTransMgr manager)
Called when a connection is established.void
onDisposed(SessionTransMgr manager)
Called when a connection is disposed of.void
onPause(SessionTransMgr manager)
Called when a connection is paused.void
onReconnected(SessionTransMgr manager)
Called when a connection is reconnected.void
postClientUpdate()
Posts an update to the root property to potentially perform client transactions.void
processTransaction(SessionTransMgr manager, ReadTransaction trans)
Process incoming transaction that itself can consist of several sub-transactions.void
restartRemoteClient()
Restarts the remote client.void
sendTransaction(SendTransaction trans)
Sends the transaction to the remote party.void
setBusy(boolean isBusy)
Sets the client session busy state.void
setBusy(boolean isBusy, java.lang.String msg, int delay, int progress)
Sets the client session busy state.void
showMessageInClient(int severity, java.lang.String heading, java.lang.String msg)
Sends an error message to be displayed on the client immediately.void
updateAuthentication(ReadTransaction trans)
Updates the current user with a password that is encrypted in AES/CBC 256-bit.
Method Detail
getClientParams
public ClientParams getClientParams()
Gets the client parameters.
onConnection
public void onConnection(SessionTransMgr manager)
Called when a connection is established.- Specified by:
onConnection
in interfaceITransactionProcessor
onPause
public void onPause(SessionTransMgr manager)
Called when a connection is paused.- Specified by:
onPause
in interfaceITransactionProcessor
onReconnected
public void onReconnected(SessionTransMgr manager)
Called when a connection is reconnected.- Specified by:
onReconnected
in interfaceITransactionProcessor
onDisposed
public void onDisposed(SessionTransMgr manager)
Called when a connection is disposed of.- Specified by:
onDisposed
in interfaceITransactionProcessor
processTransaction
public void processTransaction(SessionTransMgr manager, ReadTransaction trans)
Process incoming transaction that itself can consist of several sub-transactions.Management transaction are not present here, but GConstants.TRANS_NEXT_SERIAL that should call
manager.onNextSerialTransaction();
.- Specified by:
processTransaction
in interfaceITransactionProcessor
- Parameters:
trans
- The transaction to process.
getClientProps
public ClientProps getClientProps()
Gets the client properties.
createTransaction
public SendTransaction createTransaction()
Creates a transaction with the configured write cache.- Specified by:
createTransaction
in interfaceITransactionCreator
- Returns:
- The new
Transaction
instance.
sendTransaction
public void sendTransaction(SendTransaction trans)
Sends the transaction to the remote party.- Specified by:
sendTransaction
in interfaceIRootPropTransactionSender
- Parameters:
trans
- The transaction.
postClientUpdate
public void postClientUpdate()
Posts an update to the root property to potentially perform client transactions.
isConnected
public boolean isConnected()
Verifies that the connection is established and not paused, reconnecting, etc.- Specified by:
isConnected
in interfaceIRootPropTransactionSender
- Returns:
- true if connected, false otherwise.
restartRemoteClient
public void restartRemoteClient()
Restarts the remote client. This is done without asking anything: it will just restart the iiziRun or browser by disconnecting from server and reloading the page directly. For iiziRun Developer/Custom sessions, this will bring up that interface.
showMessageInClient
public void showMessageInClient(int severity, java.lang.String heading, java.lang.String msg)
Sends an error message to be displayed on the client immediately.- Parameters:
severity
- The message severity (-1 none, 0=info, 1=warning, 2=error).heading
- The heading text.msg
- The message text.
closeClient
public void closeClient(java.lang.String msg)
Sends an HTML message to be displayed on the client that will immediately close the connection.- Parameters:
msg
- The message text in HTML.
setBusy
public void setBusy(boolean isBusy)
Sets the client session busy state.- Parameters:
isBusy
- The busy state.
setBusy
public void setBusy(boolean isBusy, java.lang.String msg, int delay, int progress)
Sets the client session busy state.- Parameters:
isBusy
- The busy state (must be true to display message or progress).msg
- Message to display in HTML format, null for none, ignored when "ready" (busy=false).delay
- Delay in milliseconds: -2=default, -1=disabled, 0=no delay, >0 to 20000 delay in milliseconds.progress
- The progress state: -1 for none, otherwise a value between 0 and 100.
getLockSerial
public int getLockSerial()
Returns the lock serial number.- Returns:
- Serial between 0 and 0xFFFF.
getClientContextMenuReference
public java.lang.String getClientContextMenuReference(UIContextMenu contextMenu)
Gets the reference to use for a context menu.- Specified by:
getClientContextMenuReference
in interfaceIRootPropTransactionSender
- Parameters:
contextMenu
- The context menu.- Returns:
- The reference to use, empty string for none (never null).
appendPublicKey
public void appendPublicKey(SendTransaction trans)
Appends the server public key for the Diffie-Hellman key exchange with the client.- Specified by:
appendPublicKey
in interfaceIClientTransactionProcessor
- Parameters:
trans
- The transaction.
updateAuthentication
public void updateAuthentication(ReadTransaction trans) throws java.lang.Exception
Updates the current user with a password that is encrypted in AES/CBC 256-bit.- Specified by:
updateAuthentication
in interfaceIClientTransactionProcessor
- Parameters:
trans
- The transaction- Throws:
java.lang.Exception
- If there is any kind of problem with the authentication, transaction, encryption or alike.