Interface Gateway
- All Known Implementing Classes:
ConnectionMonitoringGateway
,ReconnectingGateway
,TcpGateway
public interface Gateway
Represents a gateway capable of sending and receiving messages to or/and from other systems.
- Author:
- uros.bregar
-
Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
Attempts to establish a connection to the remote site.void
disconnect
(boolean dueToError) Drops the established connection.getId()
Gets gateway id (hostname, port, ...)long
Gets last timestamp in unix millis when the last msg was receivedboolean
Gets a value specifying whether the connection to the remote site is established.void
sendData
(byte[] data) Sends data through the currentGateway
.void
setListener
(GatewayListener listener) Sets theGatewayListener
used to observe the currentGateway
implementation.
-
Method Details
-
setListener
Sets theGatewayListener
used to observe the currentGateway
implementation.- Parameters:
listener
- theGatewayListener
used to observe the currentGateway
implementation or a null reference if observation is not required.
-
sendData
Sends data through the currentGateway
.- Parameters:
data
- data to send.- Throws:
IllegalArgumentException
- Thedata
is a null reference or an empty arrayIOException
- connection problem
-
connect
Attempts to establish a connection to the remote site.- Throws:
IOException
- There was an error establishing the connection.
-
disconnect
void disconnect(boolean dueToError) Drops the established connection.- Parameters:
dueToError
- - when false user wished to close connection; when true there was a problem and we had to close it
-
isConnected
boolean isConnected()Gets a value specifying whether the connection to the remote site is established.- Returns:
- Value specifying whether the connection to the remote site is established.
-
getLastReceivedMsgTimestamp
long getLastReceivedMsgTimestamp()Gets last timestamp in unix millis when the last msg was received- Returns:
- timestamp when the last msg was received
-
getId
String getId()Gets gateway id (hostname, port, ...)- Returns:
- gateway identification
-