Class SocketBasedConnector
java.lang.Object
com.thecoderscorner.menu.remote.SharedStreamConnection
com.thecoderscorner.menu.remote.StreamRemoteConnector
com.thecoderscorner.menu.remote.socket.SocketBasedConnector
- All Implemented Interfaces:
RemoteConnector,RemoteDevice,RemoteConnectorContext
A remote connector that will communicate using a client socket. Normally configured with a host and port. Create
using the builder below.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.thecoderscorner.menu.remote.StreamRemoteConnector
StreamRemoteConnector.ReadMode -
Field Summary
Fields inherited from class com.thecoderscorner.menu.remote.StreamRemoteConnector
clock, executor, stateMachineMappingsFields inherited from class com.thecoderscorner.menu.remote.SharedStreamConnection
cmdBuffer, inputBuffer, logger, MAX_MSG_EXPECTED, protocol -
Constructor Summary
ConstructorsConstructorDescriptionSocketBasedConnector(LocalIdentifier localId, ScheduledExecutorService executor, Clock clock, MenuCommandProtocol protocol, String remoteHost, int remotePort, ConnectMode mode) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Force close a connection when its known to be bad, the connector will try and establish a new connection.protected voidgetAtLeastBytes(ByteBuffer inputBuffer, int len, StreamRemoteConnector.ReadMode mode) Reads at least the number of bytes requested waiting if need be for more data.Gets the name of this connector locallybooleanIndicates if the underlying device is actually connected.voidprotected voidsendInternal(ByteBuffer outputBuffer) performs a send of all bytes in the output buffer until the output buffer is emptyvoidstart()Starts the communication channel, so it will attempt to connect with the configured devicevoidstop()Stops the library and attempts to also stop any threads and other resources associated.Methods inherited from class com.thecoderscorner.menu.remote.StreamRemoteConnector
canSendMessageNow, changeState, changeState, connectionLog, getAuthenticationStatus, getClock, getRemoteParty, getScheduledExecutor, getUserName, handleCoreConnectionStates, notifyConnection, notifyListeners, registerConnectionChangeListener, registerConnectorListener, sendAcknowledgement, sendHeartbeat, sendJoin, sendPairing, setRemoteParty, startThreadProc, stopThreadProcMethods inherited from class com.thecoderscorner.menu.remote.SharedStreamConnection
connectionLog, doesBufferHaveEOM, 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
sendMenuCommandMethods inherited from interface com.thecoderscorner.menu.remote.states.RemoteConnectorContext
readCommandFromStream
-
Constructor Details
-
Method Details
-
start
public void start()Description copied from interface:RemoteConnectorStarts the communication channel, so it will attempt to connect with the configured device -
stop
public void stop()Description copied from interface:RemoteConnectorStops the library and attempts to also stop any threads and other resources associated. -
performConnection
- Throws:
IOException
-
sendInternal
Description copied from class:StreamRemoteConnectorperforms a send of all bytes in the output buffer until the output buffer is empty- Specified by:
sendInternalin classStreamRemoteConnector- Parameters:
outputBuffer- the buffer data to be sent- Throws:
IOException- if there are problems writing
-
isDeviceConnected
public boolean isDeviceConnected()Description copied from interface:RemoteConnectorIndicates if the underlying device is actually connected.- Specified by:
isDeviceConnectedin interfaceRemoteConnector- Specified by:
isDeviceConnectedin interfaceRemoteConnectorContext- Specified by:
isDeviceConnectedin classSharedStreamConnection- Returns:
- true if the underlying device is connected
-
getConnectionName
Description copied from interface:RemoteConnectorGets the name of this connector locally- Specified by:
getConnectionNamein interfaceRemoteConnector- Specified by:
getConnectionNamein interfaceRemoteConnectorContext- Specified by:
getConnectionNamein interfaceRemoteDevice- Specified by:
getConnectionNamein classSharedStreamConnection
-
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- Overrides:
closein classStreamRemoteConnector
-