RemoteConnectorRs232RemoteConnector, SocketBasedConnectorpublic abstract class StreamRemoteConnector extends Object implements RemoteConnector
| Modifier and Type | Class | Description |
|---|---|---|
static class |
StreamRemoteConnector.StreamState |
| Modifier and Type | Field | Description |
|---|---|---|
protected ScheduledExecutorService |
executor |
|
protected org.slf4j.Logger |
logger |
|
static byte |
START_OF_MSG |
|
protected AtomicReference<StreamRemoteConnector.StreamState> |
state |
| Modifier | Constructor | Description |
|---|---|---|
protected |
StreamRemoteConnector(MenuCommandProtocol protocol,
ScheduledExecutorService executor) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
Force close a connection when its known to be bad, the connector will try and
establish a new connection.
|
static boolean |
doesBufferHaveEOM(ByteBuffer inputBuffer) |
|
protected abstract void |
getAtLeastBytes(ByteBuffer inputBuffer,
int len) |
Reads at least the number of bytes requested waiting if need be for more data.
|
boolean |
isConnected() |
Gets the underlying connection state for this connector.
|
protected void |
logByteBuffer(String msg,
ByteBuffer inBuffer) |
Helper method that logs the entire message buffer when at debug logging level.
|
protected void |
notifyConnection() |
Helper method that notifies all connection listeners of a change in connectivity
|
protected void |
processMessagesOnConnection() |
This is the loop that handles a connection by reading messages until there's an IOException, or the transport
or thread change to an end state.
|
protected void |
readCompleteMessage(ByteBuffer inputBuffer) |
|
void |
registerConnectionChangeListener(ConnectionChangeListener listener) |
Register for connection change events, when there is a change in connectivity status
on the underlying transport.
|
void |
registerConnectorListener(RemoteConnectorListener listener) |
Register for connector messages, when new messages are received from this stream.
|
protected abstract void |
sendInternal(ByteBuffer outputBuffer) |
performs a send of all bytes in the output buffer until the output buffer is empty
|
void |
sendMenuCommand(MenuCommand msg) |
Sends a command to the remote with the protocol and usual headers.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConnectionName, start, stoppublic static final byte START_OF_MSG
protected final org.slf4j.Logger logger
protected final ScheduledExecutorService executor
protected final AtomicReference<StreamRemoteConnector.StreamState> state
protected StreamRemoteConnector(MenuCommandProtocol protocol, ScheduledExecutorService executor)
protected void processMessagesOnConnection()
public void close()
RemoteConnectorclose in interface RemoteConnectorpublic boolean isConnected()
RemoteConnectorisConnected in interface RemoteConnectorpublic void sendMenuCommand(MenuCommand msg) throws IOException
sendMenuCommand in interface RemoteConnectormsg - the message to send.IOException - if there are issues with the transportprotected abstract void sendInternal(ByteBuffer outputBuffer) throws IOException
outputBuffer - the buffer data to be sentIOException - if there are problems writingprotected abstract void getAtLeastBytes(ByteBuffer inputBuffer, int len) throws IOException
inputBuffer - the buffer to read fromlen - the minimum number of bytes neededIOException - if there are problems reading.protected void readCompleteMessage(ByteBuffer inputBuffer) throws IOException
IOExceptionpublic void registerConnectorListener(RemoteConnectorListener listener)
registerConnectorListener in interface RemoteConnectorlistener - the listener to be registeredpublic void registerConnectionChangeListener(ConnectionChangeListener listener)
registerConnectionChangeListener in interface RemoteConnectorlistener - the listenerprotected void notifyConnection()
protected void logByteBuffer(String msg, ByteBuffer inBuffer)
msg - the message to print firstinBuffer - the buffer to be loggedpublic static boolean doesBufferHaveEOM(ByteBuffer inputBuffer)
Copyright © 2018. All rights reserved.