tcMenuJavaAPI
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
com.thecoderscorner.menu.remote.StreamRemoteConnector Class Referenceabstract
Inheritance diagram for com.thecoderscorner.menu.remote.StreamRemoteConnector:
com.thecoderscorner.menu.remote.SharedStreamConnection com.thecoderscorner.menu.remote.RemoteConnector com.thecoderscorner.menu.remote.states.RemoteConnectorContext com.thecoderscorner.menu.remote.RemoteDevice com.thecoderscorner.menu.remote.socket.SocketBasedConnector

Classes

enum  ReadMode
 

Public Member Functions

boolean canSendMessageNow (MenuCommand cmd)
 
void close ()
 
void registerConnectorListener (RemoteConnectorListener listener)
 
void registerConnectionChangeListener (ConnectionChangeListener listener)
 
void notifyListeners (MenuCommand mc)
 
void changeState (AuthStatus desiredState)
 
void changeState (RemoteConnectorState newState)
 
RemoteInformation getRemoteParty ()
 
void setRemoteParty (RemoteInformation remote)
 
AuthStatus getAuthenticationStatus ()
 
void sendHeartbeat (int frequency, MenuHeartbeatCommand.HeartbeatMode mode)
 
void sendJoin () throws IOException
 
void sendAcknowledgement (AckStatus ackStatus) throws IOException
 
void sendPairing () throws IOException
 
ScheduledExecutorService getScheduledExecutor ()
 
Clock getClock ()
 
String getUserName ()
 
- Public Member Functions inherited from com.thecoderscorner.menu.remote.SharedStreamConnection
MenuCommand readCommandFromStream () throws IOException
 
void sendMenuCommand (MenuCommand msg) throws IOException
 
abstract boolean isDeviceConnected ()
 
abstract String getConnectionName ()
 
- Public Member Functions inherited from com.thecoderscorner.menu.remote.RemoteConnector
void start ()
 
void stop ()
 
void sendMenuCommand (MenuCommand msg) throws IOException
 
String getConnectionName ()
 
boolean isDeviceConnected ()
 
- Public Member Functions inherited from com.thecoderscorner.menu.remote.states.RemoteConnectorContext
MenuCommand readCommandFromStream () throws IOException
 
boolean isDeviceConnected ()
 
void performConnection () throws IOException
 
String getConnectionName ()
 

Protected Member Functions

 StreamRemoteConnector (LocalIdentifier ourLocalId, MenuCommandProtocol protocol, ScheduledExecutorService executor, Clock clock)
 
void stopThreadProc ()
 
void startThreadProc ()
 
void handleCoreConnectionStates (ConnectMode connectMode)
 
abstract void sendInternal (ByteBuffer outputBuffer) throws IOException
 
void notifyConnection ()
 
void connectionLog (System.Logger.Level l, String s, Throwable e)
 
- Protected Member Functions inherited from com.thecoderscorner.menu.remote.SharedStreamConnection
 SharedStreamConnection (MenuCommandProtocol protocol)
 
void readCompleteMessage (ByteBuffer inputBuffer) throws IOException
 
abstract void getAtLeastBytes (ByteBuffer inputBuffer, int len, StreamRemoteConnector.ReadMode mode) throws IOException
 
void logByteBuffer (String msg, ByteBuffer inBuffer)
 
void connectionLog (System.Logger.Level l, String s)
 

Protected Attributes

final ScheduledExecutorService executor
 
final Clock clock
 
final Map< AuthStatus, Class<? extends RemoteConnectorState > > stateMachineMappings = new HashMap<>()
 
- Protected Attributes inherited from com.thecoderscorner.menu.remote.SharedStreamConnection
final System.Logger logger = System.getLogger(getClass().getSimpleName())
 
final MenuCommandProtocol protocol
 
final ByteBuffer inputBuffer = ByteBuffer.allocate(MAX_MSG_EXPECTED).order(ByteOrder.BIG_ENDIAN)
 
final ByteBuffer cmdBuffer = ByteBuffer.allocate(MAX_MSG_EXPECTED).order(ByteOrder.BIG_ENDIAN)
 

Additional Inherited Members

- Static Public Member Functions inherited from com.thecoderscorner.menu.remote.SharedStreamConnection
static boolean doesBufferHaveEOM (ByteBuffer inputBuffer)
 
- Static Protected Attributes inherited from com.thecoderscorner.menu.remote.SharedStreamConnection
static final int MAX_MSG_EXPECTED = 1024
 

Detailed Description

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.


Class Documentation

◆ com::thecoderscorner::menu::remote::StreamRemoteConnector::ReadMode

enum com::thecoderscorner::menu::remote::StreamRemoteConnector::ReadMode
Enumerator
ONLY_WHEN_EMPTY
READ_MORE

Member Function Documentation

◆ close()

void com.thecoderscorner.menu.remote.StreamRemoteConnector.close ( )

Force close a connection when its known to be bad, the connector will try and establish a new connection.

Implements com.thecoderscorner.menu.remote.RemoteConnector.

Reimplemented in com.thecoderscorner.menu.remote.socket.SocketBasedConnector.

◆ getAuthenticationStatus()

AuthStatus com.thecoderscorner.menu.remote.StreamRemoteConnector.getAuthenticationStatus ( )
Returns
the status of the connection and authentication.

Implements com.thecoderscorner.menu.remote.RemoteConnector.

◆ getRemoteParty()

RemoteInformation com.thecoderscorner.menu.remote.StreamRemoteConnector.getRemoteParty ( )
Returns
the remote party information of the current connection

Implements com.thecoderscorner.menu.remote.RemoteConnector.

◆ notifyConnection()

void com.thecoderscorner.menu.remote.StreamRemoteConnector.notifyConnection ( )
protected

Helper method that notifies all connection listeners of a change in connectivity

◆ notifyListeners()

void com.thecoderscorner.menu.remote.StreamRemoteConnector.notifyListeners ( MenuCommand  mc)

Helper method that notifies all listeners of a new command message

Parameters
mcthe message to notify

Implements com.thecoderscorner.menu.remote.states.RemoteConnectorContext.

◆ registerConnectionChangeListener()

void com.thecoderscorner.menu.remote.StreamRemoteConnector.registerConnectionChangeListener ( ConnectionChangeListener  listener)

Register for connection change events, when there is a change in connectivity status on the underlying transport.

Parameters
listenerthe listener

Implements com.thecoderscorner.menu.remote.RemoteConnector.

◆ registerConnectorListener()

void com.thecoderscorner.menu.remote.StreamRemoteConnector.registerConnectorListener ( RemoteConnectorListener  listener)

Register for connector messages, when new messages are received from this stream.

Parameters
listenerthe listener to be registered

Implements com.thecoderscorner.menu.remote.RemoteConnector.

◆ sendInternal()

abstract void com.thecoderscorner.menu.remote.StreamRemoteConnector.sendInternal ( ByteBuffer  outputBuffer) throws IOException
abstractprotected

performs a send of all bytes in the output buffer until the output buffer is empty

Parameters
outputBufferthe buffer data to be sent
Exceptions
IOExceptionif there are problems writing

Reimplemented from com.thecoderscorner.menu.remote.SharedStreamConnection.

Reimplemented in com.thecoderscorner.menu.remote.socket.SocketBasedConnector.


The documentation for this class was generated from the following file: