Package de.das.encrypter.processors
Class TransferControl
java.lang.Object
de.das.encrypter.processors.TransferControl
- All Implemented Interfaces:
DataReceiver
Class for managing the transmission process between a block sender and the
associated receiver. It implements the DataReceiver interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe result of a performed transfer indicates that the transfer was performed with an error.static final intThis flag indicates that not yet any result has been detected.static final StringString used for testing whether a receiver is available.static final StringString that the receiver sends as a response if it was addressed by the sender with the PARTNER_ID + key ID.static final intThe result of a performed transfer indicates that the transfer was performed successfully.static final StringString that the receiver sends as a response if errors occur during reception and evaluation or use of the received data and regular reception cannot be performed. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of a transfer control. -
Method Summary
Modifier and TypeMethodDescriptionintintReturns the result of a performed transfer.booleanbooleanbooleanbooleanbooleanvoidsetBreakSender(boolean breakSender) voidsetData(byte[] data) Passes the received data to the instance of the class that implements the DataReceiver interface and has registered with the UDP receiver.voidPasses the received data and the IP-address of the sender to the instance of the class that implements the DataReceiver interface and has registered with the UDP receiver.voidsetFrameId(int frameId) voidvoidsetNextFrame(boolean nextFrame) voidsetResponse(boolean response) voidsetTransferResult(int res) Sets the result of the performed transfer.voidsetupSender(String host, int port) voidsetWaitForResponse(boolean waitForResponse) voidsetWaitingForInfo(boolean b)
-
Field Details
-
PARTNER_ID
String used for testing whether a receiver is available. Together with this string the ID of the current key is sent and the recipient replies with "Ready:OK" if he also has exactly this key, otherwise with "Ready:NOK".- See Also:
-
PARTNER_RESPONSE
String that the receiver sends as a response if it was addressed by the sender with the PARTNER_ID + key ID. It completes the response with "OK" if it also possesses the key with the sent key ID and with "NOK" if it does not possess this key.- See Also:
-
TRANSFER_BREAK
String that the receiver sends as a response if errors occur during reception and evaluation or use of the received data and regular reception cannot be performed.- See Also:
-
NO_RESULT
public static final int NO_RESULTThis flag indicates that not yet any result has been detected.- See Also:
-
SUCCESS
public static final int SUCCESSThe result of a performed transfer indicates that the transfer was performed successfully.- See Also:
-
FAILURE
public static final int FAILUREThe result of a performed transfer indicates that the transfer was performed with an error.- See Also:
-
-
Constructor Details
-
TransferControl
Creates a new instance of a transfer control.- Parameters:
rr- an instance of a class which implements the interface ResultReceiver.
-
-
Method Details
-
setupSender
- Parameters:
host-port-- Throws:
Exception
-
setHost
- Throws:
Exception
-
isResponse
public boolean isResponse() -
setResponse
public void setResponse(boolean response) -
isWaitForResponse
public boolean isWaitForResponse() -
setWaitForResponse
public void setWaitForResponse(boolean waitForResponse) -
isNextFrame
public boolean isNextFrame() -
setNextFrame
public void setNextFrame(boolean nextFrame) -
getFrameId
public int getFrameId() -
setFrameId
public void setFrameId(int frameId) -
isBreakSender
public boolean isBreakSender() -
setBreakSender
public void setBreakSender(boolean breakSender) -
getSender
-
isWaitingForInfo
public boolean isWaitingForInfo() -
setWaitingForInfo
public void setWaitingForInfo(boolean b) -
setData
Description copied from interface:DataReceiverPasses the received data and the IP-address of the sender to the instance of the class that implements the DataReceiver interface and has registered with the UDP receiver.- Specified by:
setDatain interfaceDataReceiver- Parameters:
host- the IP address of the sender.bytes- the byte array received by a UDP receiver.
-
setData
public void setData(byte[] data) Description copied from interface:DataReceiverPasses the received data to the instance of the class that implements the DataReceiver interface and has registered with the UDP receiver.- Specified by:
setDatain interfaceDataReceiver- Parameters:
data- the byte array received by a UDP receiver.
-
setTransferResult
public void setTransferResult(int res) Sets the result of the performed transfer.- Parameters:
res- the result of the performed transfer.
-
getTransferResult
public int getTransferResult()Returns the result of a performed transfer.- Returns:
- the result of a performed transfer.
-