tcMenuJavaAPI
Public Member Functions | Protected Member Functions | List of all members
com.thecoderscorner.menu.remote.socket.SocketBasedConnector Class Reference
Inheritance diagram for com.thecoderscorner.menu.remote.socket.SocketBasedConnector:
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

Public Member Functions

 SocketBasedConnector (LocalIdentifier localId, ScheduledExecutorService executor, Clock clock, MenuCommandProtocol protocol, String remoteHost, int remotePort, ConnectMode mode)
 
void start ()
 
void stop ()
 
void performConnection () throws IOException
 
boolean isDeviceConnected ()
 
String getConnectionName ()
 
void close ()
 
- Public Member Functions inherited from com.thecoderscorner.menu.remote.StreamRemoteConnector
boolean canSendMessageNow (MenuCommand cmd)
 
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
 
- Public Member Functions inherited from com.thecoderscorner.menu.remote.RemoteConnector
void sendMenuCommand (MenuCommand msg) throws IOException
 
- Public Member Functions inherited from com.thecoderscorner.menu.remote.states.RemoteConnectorContext
MenuCommand readCommandFromStream () throws IOException
 

Protected Member Functions

void getAtLeastBytes (ByteBuffer inputBuffer, int len, ReadMode mode) throws IOException
 
void sendInternal (ByteBuffer outputBuffer) throws IOException
 
- Protected Member Functions inherited from com.thecoderscorner.menu.remote.StreamRemoteConnector
 StreamRemoteConnector (LocalIdentifier ourLocalId, MenuCommandProtocol protocol, ScheduledExecutorService executor, Clock clock)
 
void stopThreadProc ()
 
void startThreadProc ()
 
void handleCoreConnectionStates (ConnectMode connectMode)
 
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
 
void logByteBuffer (String msg, ByteBuffer inBuffer)
 
void connectionLog (System.Logger.Level l, String s)
 

Additional Inherited Members

- Static Public Member Functions inherited from com.thecoderscorner.menu.remote.SharedStreamConnection
static boolean doesBufferHaveEOM (ByteBuffer inputBuffer)
 
- Protected Attributes inherited from com.thecoderscorner.menu.remote.StreamRemoteConnector
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)
 
- Static Protected Attributes inherited from com.thecoderscorner.menu.remote.SharedStreamConnection
static final int MAX_MSG_EXPECTED = 1024
 

Detailed Description

A remote connector that will communicate using a client socket. Normally configured with a host and port. Create using the builder below.

See also
SocketControllerBuilder

Member Function Documentation

◆ close()

void com.thecoderscorner.menu.remote.socket.SocketBasedConnector.close ( )

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

Reimplemented from com.thecoderscorner.menu.remote.StreamRemoteConnector.

◆ getAtLeastBytes()

void com.thecoderscorner.menu.remote.socket.SocketBasedConnector.getAtLeastBytes ( ByteBuffer  inputBuffer,
int  len,
ReadMode  mode 
) throws IOException
protected

Reads at least the number of bytes requested waiting if need be for more data.

Parameters
inputBufferthe buffer to read from
lenthe minimum number of bytes needed
Exceptions
IOExceptionif there are problems reading.

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

◆ getConnectionName()

String com.thecoderscorner.menu.remote.socket.SocketBasedConnector.getConnectionName ( )

Gets the name of this connector locally

Implements com.thecoderscorner.menu.remote.RemoteConnector.

◆ isDeviceConnected()

boolean com.thecoderscorner.menu.remote.socket.SocketBasedConnector.isDeviceConnected ( )

Indicates if the underlying device is actually connected.

Returns
true if the underlying device is connected

Implements com.thecoderscorner.menu.remote.RemoteConnector.

◆ sendInternal()

void com.thecoderscorner.menu.remote.socket.SocketBasedConnector.sendInternal ( ByteBuffer  outputBuffer) throws IOException
protected

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.StreamRemoteConnector.

◆ start()

void com.thecoderscorner.menu.remote.socket.SocketBasedConnector.start ( )

Starts the communication channel, so it will attempt to connect with the configured device

Implements com.thecoderscorner.menu.remote.RemoteConnector.

◆ stop()

void com.thecoderscorner.menu.remote.socket.SocketBasedConnector.stop ( )

Stops the library and attempts to also stop any threads and other resources associated.

Implements com.thecoderscorner.menu.remote.RemoteConnector.


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