Class AppClient

java.lang.Object
jmri.jmrit.z21server.AppClient
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class AppClient extends Object implements PropertyChangeListener
This class represents a connected and registered client, e.g. a Z21 app or a WlanMaus JMRI throttles a bound to this client.
  • Constructor Details

    • AppClient

      public AppClient(InetAddress address, PropertyChangeListener changeListener)
      Constructor.
      Parameters:
      address - of the connected client
      changeListener - to be called if one of the throttles has changed
  • Method Details

    • addThrottle

      public void addThrottle(int locoAddress, DccThrottle throttle)
      Add a throttle to the clients list of throttles. The throttle instance is created by the caller.
      Parameters:
      locoAddress - - the loco address
      throttle - - the throttle to be added
    • getActiveThrottle

      Get the last used throttle
      Returns:
      last used throttle
    • getActiveRosterIdString

      Get the roster ID for the last used throttle
      Returns:
      roster ID as String
    • setActiveThrottle

      public void setActiveThrottle(DccThrottle t)
      Set last used throttle
      Parameters:
      t - is the throttle
    • clear

      public void clear()
      Remove the listener from all throttles and clear the list of throttles.
    • getThrottleFromLocoAddress

      public DccThrottle getThrottleFromLocoAddress(int locoAddress)
      Get a throttle by loco address
      Parameters:
      locoAddress - - the loco address
      Returns:
      the throttle
    • getAddress

      Get clients IP address
      Returns:
      the InetAddress
    • heartbeat

      public void heartbeat()
      The heartbeat for client expire
    • isTimestampExpired

      public boolean isTimestampExpired()
      Check if the client has not been seen (see heartbeat()) for at least 60 seconds.
      Returns:
      true if not seen for more than 60 seconds
    • getLocoStatusMessage

      public byte[] getLocoStatusMessage(Integer locoAddress)
      Return a Z21 LAN_X_LOCO_INFO packet for a given loco address
      Parameters:
      locoAddress - - the loco address
      Returns:
      Z21 LAN_X_LOCO_INFO packet
    • propertyChange

      Listener for throttle events. Will call the changeListener (in MainServer) with the Z21 LAN_X_LOCO_INFO packet as new value.
      Specified by:
      propertyChange in interface PropertyChangeListener
      Parameters:
      pce - - throttle change event
    • findRosterEntry

      Find the roster entry from a given throttle instance.
      Parameters:
      t - - the throttle instance
      Returns:
      the roster entry