java.lang.Object
com.sportradar.livedata.sdk.common.networking.TcpGateway
All Implemented Interfaces:
Gateway

public class TcpGateway extends Object implements Gateway
A Gateway implementation which uses TCP protocol stack to communicate.
Author:
uros.bregar
  • Constructor Details

  • Method Details

    • setListener

      public void setListener(GatewayListener listener)
      Sets the GatewayListener used to observe the current Gateway implementation.
      Specified by:
      setListener in interface Gateway
      Parameters:
      listener - the GatewayListener used to observe the current Gateway implementation or a null reference if observation is not required.
    • sendData

      public void sendData(byte[] data) throws IOException
      Sends data through the current Gateway.
      Specified by:
      sendData in interface Gateway
      Parameters:
      data - data to send.
      Throws:
      IllegalArgumentException - The data is a null reference or an empty array
      IOException - connection problem
    • connect

      public void connect() throws IOException
      Attempts to establish a connection to the remote site.
      Specified by:
      connect in interface Gateway
      Throws:
      IOException - There was an error establishing the connection.
    • disconnect

      public void disconnect(boolean dueToError)
      Drops the established connection.
      Specified by:
      disconnect in interface Gateway
      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:
      isConnected in interface Gateway
      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:
      getLastReceivedMsgTimestamp in interface Gateway
      Returns:
      timestamp when the last msg was received
    • getId

      public String getId()
      Description copied from interface: Gateway
      Gets gateway id (hostname, port, ...)
      Specified by:
      getId in interface Gateway
      Returns:
      gateway identification