Class SharedStreamConnection

java.lang.Object
com.thecoderscorner.menu.remote.SharedStreamConnection
Direct Known Subclasses:
StreamRemoteConnector

public abstract class SharedStreamConnection extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • readCommandFromStream

      public MenuCommand readCommandFromStream() throws IOException
      Throws:
      IOException
    • doesBufferHaveEOM

      public static boolean doesBufferHaveEOM(ByteBuffer inputBuffer)
    • readCompleteMessage

      protected void readCompleteMessage(ByteBuffer inputBuffer) throws IOException
      Throws:
      IOException
    • getAtLeastBytes

      protected abstract void getAtLeastBytes(ByteBuffer inputBuffer, int len, StreamRemoteConnector.ReadMode mode) throws IOException
      Reads at least the number of bytes requested waiting if need be for more data.
      Parameters:
      inputBuffer - the buffer to read from
      len - the minimum number of bytes needed
      Throws:
      IOException - if there are problems reading.
    • logByteBuffer

      protected void logByteBuffer(String msg, ByteBuffer inBuffer)
      Helper method that logs the entire message buffer when at debug logging level.
      Parameters:
      msg - the message to print first
      inBuffer - the buffer to be logged
    • sendMenuCommand

      public void sendMenuCommand(MenuCommand msg) throws IOException
      Sends a command to the remote with the protocol and usual headers.
      Parameters:
      msg - the message to send.
      Throws:
      IOException - if there are issues with the transport
    • connectionLog

      protected void connectionLog(System.Logger.Level l, String s)
    • sendInternal

      protected abstract void sendInternal(ByteBuffer cmdBuffer) throws IOException
      Throws:
      IOException
    • isDeviceConnected

      public abstract boolean isDeviceConnected()
    • getConnectionName

      public abstract String getConnectionName()
    • canSendMessageNow

      public abstract boolean canSendMessageNow(MenuCommand cmd)