Package jmri.jmrit.z21server
Class AppClient
java.lang.Object
jmri.jmrit.z21server.AppClient
- All Implemented Interfaces:
PropertyChangeListener,EventListener
This class represents a connected and registered client, e.g. a Z21 app or a WlanMaus
JMRI throttles a bound to this client.
-
Constructor Summary
ConstructorsConstructorDescriptionAppClient(InetAddress address, PropertyChangeListener changeListener) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddThrottle(int locoAddress, DccThrottle throttle) Add a throttle to the clients list of throttles.voidclear()Remove the listener from all throttles and clear the list of throttles.static RosterEntryFind the roster entry from a given throttle instance.Get the roster ID for the last used throttleGet the last used throttleGet clients IP addressbyte[]getLocoStatusMessage(Integer locoAddress) Return a Z21 LAN_X_LOCO_INFO packet for a given loco addressgetThrottleFromLocoAddress(int locoAddress) Get a throttle by loco addressvoidThe heartbeat for client expirebooleanCheck if the client has not been seen (see heartbeat()) for at least 60 seconds.voidListener for throttle events.voidSet last used throttle
-
Constructor Details
-
AppClient
Constructor.- Parameters:
address- of the connected clientchangeListener- to be called if one of the throttles has changed
-
-
Method Details
-
addThrottle
Add a throttle to the clients list of throttles. The throttle instance is created by the caller.- Parameters:
locoAddress- - the loco addressthrottle- - 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
Set last used throttle- Parameters:
t- is the throttle
-
clear
Remove the listener from all throttles and clear the list of throttles. -
getThrottleFromLocoAddress
Get a throttle by loco address- Parameters:
locoAddress- - the loco address- Returns:
- the throttle
-
getAddress
Get clients IP address- Returns:
- the InetAddress
-
heartbeat
The heartbeat for client expire -
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
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:
propertyChangein interfacePropertyChangeListener- Parameters:
pce- - throttle change event
-
findRosterEntry
Find the roster entry from a given throttle instance.- Parameters:
t- - the throttle instance- Returns:
- the roster entry
-