Package com.thecoderscorner.menu.remote
Class StreamRemoteConnector
java.lang.Object
com.thecoderscorner.menu.remote.SharedStreamConnection
com.thecoderscorner.menu.remote.StreamRemoteConnector
- All Implemented Interfaces:
RemoteConnector,RemoteConnectorContext
- Direct Known Subclasses:
SocketBasedConnector
public abstract class StreamRemoteConnector
extends SharedStreamConnection
implements RemoteConnector, RemoteConnectorContext
Stream remote connector is the base class for all stream implementations, such as Socket and RS232. Any remote
with stream like semantics can use this as the base for building out an adapter.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Clockprotected final ScheduledExecutorServiceprotected final Map<AuthStatus,Class<? extends RemoteConnectorState>> Fields inherited from class com.thecoderscorner.menu.remote.SharedStreamConnection
cmdBuffer, inputBuffer, logger, MAX_MSG_EXPECTED, protocol -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStreamRemoteConnector(LocalIdentifier ourLocalId, MenuCommandProtocol protocol, ScheduledExecutorService executor, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidchangeState(AuthStatus desiredState) voidchangeState(RemoteConnectorState newState) voidclose()Force close a connection when its known to be bad, the connector will try and establish a new connection.protected voidconnectionLog(System.Logger.Level l, String s, Throwable e) getClock()protected voidhandleCoreConnectionStates(ConnectMode connectMode) protected voidHelper method that notifies all connection listeners of a change in connectivityvoidHelper method that notifies all listeners of a new command messagevoidRegister for connection change events, when there is a change in connectivity status on the underlying transport.voidRegister for connector messages, when new messages are received from this stream.voidsendAcknowledgement(AckStatus ackStatus) voidsendHeartbeat(int frequency, MenuHeartbeatCommand.HeartbeatMode mode) protected abstract voidsendInternal(ByteBuffer outputBuffer) performs a send of all bytes in the output buffer until the output buffer is emptyvoidsendJoin()voidvoidsetRemoteParty(RemoteInformation remote) protected voidprotected voidMethods inherited from class com.thecoderscorner.menu.remote.SharedStreamConnection
connectionLog, doesBufferHaveEOM, getAtLeastBytes, getConnectionName, isDeviceConnected, logByteBuffer, readCommandFromStream, readCompleteMessage, sendMenuCommandMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.thecoderscorner.menu.remote.RemoteConnector
getConnectionName, isDeviceConnected, sendMenuCommand, start, stopMethods inherited from interface com.thecoderscorner.menu.remote.states.RemoteConnectorContext
getConnectionName, isDeviceConnected, performConnection, readCommandFromStream
-
Field Details
-
executor
-
clock
-
stateMachineMappings
-
-
Constructor Details
-
Method Details
-
stopThreadProc
protected void stopThreadProc() -
startThreadProc
protected void startThreadProc() -
close
public void close()Description copied from interface:RemoteConnectorForce close a connection when its known to be bad, the connector will try and establish a new connection.- Specified by:
closein interfaceRemoteConnector- Specified by:
closein interfaceRemoteConnectorContext
-
sendInternal
performs a send of all bytes in the output buffer until the output buffer is empty- Specified by:
sendInternalin classSharedStreamConnection- Parameters:
outputBuffer- the buffer data to be sent- Throws:
IOException- if there are problems writing
-
notifyConnection
protected void notifyConnection()Helper method that notifies all connection listeners of a change in connectivity -
getRemoteParty
- Specified by:
getRemotePartyin interfaceRemoteConnector- Returns:
- the remote party information of the current connection
-
getAuthenticationStatus
- Specified by:
getAuthenticationStatusin interfaceRemoteConnector- Returns:
- the status of the connection and authentication.
-
sendJoin
- Specified by:
sendJoinin interfaceRemoteConnectorContext- Throws:
IOException
-
sendPairing
- Specified by:
sendPairingin interfaceRemoteConnectorContext- Throws:
IOException
-
getScheduledExecutor
- Specified by:
getScheduledExecutorin interfaceRemoteConnectorContext
-
getClock
- Specified by:
getClockin interfaceRemoteConnectorContext
-
connectionLog