Package com.thecoderscorner.menu.mgr
Interface ServerConnection
- All Superinterfaces:
RemoteDevice
- All Known Implementing Classes:
SocketServerConnection
Each connection from a remote is represented by a class implementing this interface. MenuManagerServer holds a
series of ServerConnectionManager objects, that in turn contain a series of these connections. Running connections
are managed by MenuManagerServer where it will deal with heartbeating, bootstrapping, incoming updates and sending
local updates to the remote.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose the current connection if it is openintget the username of this connectionlonglongvoidregisterConnectionListener(BiConsumer<ServerConnection, Boolean> connectionListener) Register the connection listener to this connection that will receive udpates on connection changes.voidregisterMessageHandler(BiConsumer<ServerConnection, MenuCommand> messageHandler) Register the message handler that will receive all messages from the connectionvoidsendCommand(MenuCommand command) Send a command to the remotevoidSet the connection mode for this connection, usually called by the menu manager to indicate stateMethods inherited from interface com.thecoderscorner.menu.remote.RemoteDevice
getConnectionName
-
Method Details
-
getHeartbeatFrequency
int getHeartbeatFrequency()- Returns:
- the heartbeat frequency for this connection
-
closeConnection
void closeConnection()close the current connection if it is open -
lastReceivedHeartbeat
long lastReceivedHeartbeat()- Returns:
- the last time a message was received
-
lastTransmittedHeartbeat
long lastTransmittedHeartbeat()- Returns:
- the last successful message transmission
-
registerConnectionListener
Register the connection listener to this connection that will receive udpates on connection changes.- Parameters:
connectionListener- the connection state
-
registerMessageHandler
Register the message handler that will receive all messages from the connection- Parameters:
messageHandler- the message handler
-
getConnectionMode
ServerConnectionMode getConnectionMode()- Returns:
- the connection mode for this connection
-
getUserName
String getUserName()get the username of this connection- Specified by:
getUserNamein interfaceRemoteDevice- Returns:
- the username
-