Class SocketServerConnection
java.lang.Object
com.thecoderscorner.menu.remote.SharedStreamConnection
com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection
- All Implemented Interfaces:
ServerConnection
-
Field Summary
Fields inherited from class com.thecoderscorner.menu.remote.SharedStreamConnection
cmdBuffer, inputBuffer, MAX_MSG_EXPECTED, protocol -
Constructor Summary
ConstructorsConstructorDescriptionSocketServerConnection(Socket socket, MenuCommandProtocol protocol, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclose the current connection if it is openprotected voidgetAtLeastBytes(ByteBuffer inputBuffer, int len, StreamRemoteConnector.ReadMode mode) Reads at least the number of bytes requested waiting if need be for more data.intget the username of this connectionbooleanlonglongvoidregisterConnectionListener(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 remoteprotected voidsendInternal(ByteBuffer cmdBuffer) voidSet the connection mode for this connection, usually called by the menu manager to indicate statetoString()Methods inherited from class com.thecoderscorner.menu.remote.SharedStreamConnection
connectionLog, doesBufferHaveEOM, logByteBuffer, readCommandFromStream, readCompleteMessage, sendMenuCommand
-
Constructor Details
-
Method Details
-
getHeartbeatFrequency
public int getHeartbeatFrequency()- Specified by:
getHeartbeatFrequencyin interfaceServerConnection- Returns:
- the heartbeat frequency for this connection
-
closeConnection
public void closeConnection()Description copied from interface:ServerConnectionclose the current connection if it is open- Specified by:
closeConnectionin interfaceServerConnection
-
lastReceivedHeartbeat
public long lastReceivedHeartbeat()- Specified by:
lastReceivedHeartbeatin interfaceServerConnection- Returns:
- the last time a message was received
-
lastTransmittedHeartbeat
public long lastTransmittedHeartbeat()- Specified by:
lastTransmittedHeartbeatin interfaceServerConnection- Returns:
- the last successful message transmission
-
registerConnectionListener
Description copied from interface:ServerConnectionRegister the connection listener to this connection that will receive udpates on connection changes.- Specified by:
registerConnectionListenerin interfaceServerConnection- Parameters:
connectionListener- the connection state
-
registerMessageHandler
Description copied from interface:ServerConnectionRegister the message handler that will receive all messages from the connection- Specified by:
registerMessageHandlerin interfaceServerConnection- Parameters:
messageHandler- the message handler
-
getConnectionMode
- Specified by:
getConnectionModein interfaceServerConnection- Returns:
- the connection mode for this connection
-
getUserName
Description copied from interface:ServerConnectionget the username of this connection- Specified by:
getUserNamein interfaceServerConnection- Returns:
- the username
-
sendInternal
- Specified by:
sendInternalin classSharedStreamConnection- Throws:
IOException
-
isDeviceConnected
public boolean isDeviceConnected()- Specified by:
isDeviceConnectedin classSharedStreamConnection
-
getConnectionName
- Specified by:
getConnectionNamein classSharedStreamConnection
-
toString
-