tcMenuJavaAPI
Public Member Functions | Protected Member Functions | List of all members
com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection Class Reference
Inheritance diagram for com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection:
com.thecoderscorner.menu.remote.SharedStreamConnection com.thecoderscorner.menu.mgr.ServerConnection com.thecoderscorner.menu.remote.RemoteDevice

Public Member Functions

 SocketServerConnection (Socket socket, MenuCommandProtocol protocol, Clock clock)
 
int getHeartbeatFrequency ()
 
void closeConnection ()
 
long lastReceivedHeartbeat ()
 
long lastTransmittedHeartbeat ()
 
void sendCommand (MenuCommand command)
 
void registerConnectionListener (BiConsumer< ServerConnection, Boolean > connectionListener)
 
void registerMessageHandler (BiConsumer< ServerConnection, MenuCommand > messageHandler)
 
void setConnectionMode (ServerConnectionMode mode)
 
ServerConnectionMode getConnectionMode ()
 
String getUserName ()
 
String getConnectionName ()
 
boolean isDeviceConnected ()
 
boolean canSendMessageNow (MenuCommand cmd)
 
String toString ()
 
- Public Member Functions inherited from com.thecoderscorner.menu.remote.SharedStreamConnection
MenuCommand readCommandFromStream () throws IOException
 
void sendMenuCommand (MenuCommand msg) throws IOException
 

Protected Member Functions

void getAtLeastBytes (ByteBuffer inputBuffer, int len, StreamRemoteConnector.ReadMode mode) throws IOException
 
void sendInternal (ByteBuffer cmdBuffer) throws IOException
 
- 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.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
 

Member Function Documentation

◆ closeConnection()

void com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.closeConnection ( )

close the current connection if it is open

Implements com.thecoderscorner.menu.mgr.ServerConnection.

◆ getAtLeastBytes()

void com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.getAtLeastBytes ( ByteBuffer  inputBuffer,
int  len,
StreamRemoteConnector.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.

◆ getConnectionMode()

ServerConnectionMode com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.getConnectionMode ( )
Returns
the connection mode for this connection

Implements com.thecoderscorner.menu.mgr.ServerConnection.

◆ getHeartbeatFrequency()

int com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.getHeartbeatFrequency ( )
Returns
the heartbeat frequency for this connection

Implements com.thecoderscorner.menu.mgr.ServerConnection.

◆ getUserName()

String com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.getUserName ( )

get the username of this connection

Returns
the username

Implements com.thecoderscorner.menu.mgr.ServerConnection.

◆ lastReceivedHeartbeat()

long com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.lastReceivedHeartbeat ( )
Returns
the last time a message was received

Implements com.thecoderscorner.menu.mgr.ServerConnection.

◆ lastTransmittedHeartbeat()

long com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.lastTransmittedHeartbeat ( )
Returns
the last successful message transmission

Implements com.thecoderscorner.menu.mgr.ServerConnection.

◆ registerConnectionListener()

void com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.registerConnectionListener ( BiConsumer< ServerConnection, Boolean >  connectionListener)

Register the connection listener to this connection that will receive udpates on connection changes.

Parameters
connectionListenerthe connection state

Implements com.thecoderscorner.menu.mgr.ServerConnection.

◆ registerMessageHandler()

void com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.registerMessageHandler ( BiConsumer< ServerConnection, MenuCommand messageHandler)

Register the message handler that will receive all messages from the connection

Parameters
messageHandlerthe message handler

Implements com.thecoderscorner.menu.mgr.ServerConnection.

◆ sendCommand()

void com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.sendCommand ( MenuCommand  command)

Send a command to the remote

Parameters
commandthe command to send

Implements com.thecoderscorner.menu.mgr.ServerConnection.

◆ setConnectionMode()

void com.thecoderscorner.menu.remote.mgrclient.SocketServerConnection.setConnectionMode ( ServerConnectionMode  mode)

Set the connection mode for this connection, usually called by the menu manager to indicate state

Parameters
modethe mode

Implements com.thecoderscorner.menu.mgr.ServerConnection.


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