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 |
A remote connector that will communicate using a client socket. Normally configured with a host and port. Create using the builder below.
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.
|
protected |
Reads at least the number of bytes requested waiting if need be for more data.
inputBuffer | the buffer to read from |
len | the minimum number of bytes needed |
IOException | if there are problems reading. |
Reimplemented from com.thecoderscorner.menu.remote.SharedStreamConnection.
String com.thecoderscorner.menu.remote.socket.SocketBasedConnector.getConnectionName | ( | ) |
Gets the name of this connector locally
Implements com.thecoderscorner.menu.remote.RemoteConnector.
boolean com.thecoderscorner.menu.remote.socket.SocketBasedConnector.isDeviceConnected | ( | ) |
Indicates if the underlying device is actually connected.
Implements com.thecoderscorner.menu.remote.RemoteConnector.
|
protected |
performs a send of all bytes in the output buffer until the output buffer is empty
outputBuffer | the buffer data to be sent |
IOException | if there are problems writing |
Reimplemented from com.thecoderscorner.menu.remote.StreamRemoteConnector.
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.
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.