Class SCPRequestHeader

java.lang.Object
uk.ac.manchester.spinnaker.messages.scp.SCPRequestHeader
All Implemented Interfaces:
SerializableMessage

public final class SCPRequestHeader
extends Object
implements SerializableMessage
Represents the header of an SCP Request.

The sequence number, if zero, will be set by the message sending code to the actual sequence number when the message is sent on a connection.

  • Field Details

  • Method Details

    • addToBuffer

      public void addToBuffer​(ByteBuffer buffer)
      Writes this message into the given buffer as a contiguous range of bytes. This is so that a message can be sent. Implementors may assume that the buffer has been configured to be little-endian and that its position is at the point where they should begin writing. Once it has finished, the position should be immediately after the last byte written by this method.

      Calling this method should not update the internal state of the message. It should be possible to add the message to multiple buffers without special precautions by the caller.

      This must not be called until after a sequence number is set.

      Specified by:
      addToBuffer in interface SerializableMessage
      Parameters:
      buffer - The buffer to write into.
    • issueSequenceNumber

      public int issueSequenceNumber​(Set<Integer> inFlight)
      Set the sequence number of this request to the next available number. This can only ever be called once per request.
      Parameters:
      inFlight - What sequence numbers are current in use and shouldn't be used.
      Returns:
      The number that was issued.
      Throws:
      IllegalStateException - If an attempt is made to set a sequence number a second time
    • getSequence

      public int getSequence()
      Returns:
      The message's sequence number.