Class ChunkHandler

    • Field Detail

      • CHUNK_ORDER

        public static final ByteOrder CHUNK_ORDER
      • CHUNK_FAIL

        public static final int CHUNK_FAIL
    • Constructor Detail

      • ChunkHandler

        public ChunkHandler()
    • Method Detail

      • connected

        public abstract void connected()
        Called when the DDM server connects. The handler is allowed to send messages to the server.
      • disconnected

        public abstract void disconnected()
        Called when the DDM server disconnects. Can be used to disable periodic transmissions or clean up saved state.
      • handleChunk

        public abstract Chunk handleChunk​(Chunk request)
        Handle a single chunk of data. "request" includes the type and the chunk payload. Returns a response in a Chunk.
      • createFailChunk

        public static Chunk createFailChunk​(int errorCode,
                                            String msg)
        Create a FAIL chunk. The "handleChunk" methods can use this to return an error message when they are not able to process a chunk.
      • wrapChunk

        public static ByteBuffer wrapChunk​(Chunk request)
        Utility function to wrap a ByteBuffer around a Chunk.
      • getString

        public static String getString​(ByteBuffer buf,
                                       int len)
        Utility function to copy a String out of a ByteBuffer. This is here because multiple chunk handlers can make use of it, and there's nowhere better to put it.
      • putString

        public static void putString​(ByteBuffer buf,
                                     String str)
        Utility function to copy a String into a ByteBuffer.
      • type

        public static int type​(String typeName)
        Convert a 4-character string to a 32-bit type.
      • name

        public static String name​(int type)
        Convert an integer type to a 4-character string.