Class ConnectionMonitoringGateway
java.lang.Object
com.sportradar.livedata.sdk.common.networking.ConnectionMonitoringGateway
- All Implemented Interfaces:
Gateway
A
Gateway implementation which observes the received messages to determine when the connection is unstable-
Constructor Summary
ConstructorsConstructorDescriptionConnectionMonitoringGateway(Gateway actualGateway, Timer monitorTimer, org.joda.time.Duration checkInterval, org.joda.time.Duration noActivityTimeout, boolean debugMode) Initializes a new instance of theConnectionMonitoringGatewayclass. -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Attempts to establish a connection to the remote site.voiddisconnect(boolean dueToError) Drops the established connection.getId()Gets gateway id (hostname, port, ...)longGets last timestamp in unix millis when the last msg was receivedbooleanGets a value specifying whether the connection to the remote site is established.voidsendData(byte[] data) Sends data through the currentGateway.voidsetListener(GatewayListener listener) Sets theGatewayListenerused to observe the currentGatewayimplementation.
-
Constructor Details
-
ConnectionMonitoringGateway
public ConnectionMonitoringGateway(Gateway actualGateway, Timer monitorTimer, org.joda.time.Duration checkInterval, org.joda.time.Duration noActivityTimeout, boolean debugMode) Initializes a new instance of theConnectionMonitoringGatewayclass.- Parameters:
actualGateway- the wrappedGatewayimplementation used to communicate with the server.monitorTimer- The timer used to periodically monitor the connection status.checkInterval- Check interval for socket connection.noActivityTimeout- TheDurationspecifying the time window in milliseconds after which the connection will be considered unstable if the gateway does not receive any data.debugMode- Adds debug logging.- Throws:
IllegalArgumentException- theactualGatewayis a null reference ormonitorTimeris a null reference orcheckIntervalis a null reference ornoActivityTimeoutis a null reference.
-
-
Method Details
-
setListener
Sets theGatewayListenerused to observe the currentGatewayimplementation.- Specified by:
setListenerin interfaceGateway- Parameters:
listener- theGatewayListenerused to observe the currentGatewayimplementation or a null reference if observation is not required.
-
sendData
Sends data through the currentGateway.- Specified by:
sendDatain interfaceGateway- Parameters:
data- data to send.- Throws:
IllegalArgumentException- Thedatais a null reference or an empty arrayIOException- connection problem
-
connect
Attempts to establish a connection to the remote site.- Specified by:
connectin interfaceGateway- Throws:
IOException- There was an error establishing the connection.
-
disconnect
public void disconnect(boolean dueToError) Drops the established connection.- Specified by:
disconnectin interfaceGateway- Parameters:
dueToError- - when false user wished to close connection; when true there was a problem and we had to close it
-
isConnected
public boolean isConnected()Gets a value specifying whether the connection to the remote site is established.- Specified by:
isConnectedin interfaceGateway- Returns:
- Value specifying whether the connection to the remote site is established.
-
getLastReceivedMsgTimestamp
public long getLastReceivedMsgTimestamp()Gets last timestamp in unix millis when the last msg was received- Specified by:
getLastReceivedMsgTimestampin interfaceGateway- Returns:
- timestamp when the last msg was received
-
getId
Description copied from interface:GatewayGets gateway id (hostname, port, ...)
-