Record Class Frame.ConnectionClose

java.lang.Object
java.lang.Record
io.github.mahmoudimus.quic.frame.Frame.ConnectionClose
Record Components:
errorCode - the transport error code
frameType - the type of the frame that caused the error, or 0 if unknown
reason - the reason phrase, UTF-8 by convention
All Implemented Interfaces:
Frame
Enclosing interface:
Frame

public static record Frame.ConnectionClose(long errorCode, long frameType, ByteBuffer reason) extends Record implements Frame
A CONNECTION_CLOSE frame for a transport error (type 0x1c).
  • Constructor Details

    • ConnectionClose

      public ConnectionClose(long errorCode, long frameType, ByteBuffer reason)
      A transport CONNECTION_CLOSE frame.
      Parameters:
      errorCode - the transport error code
      frameType - the type of the offending frame, or 0
      reason - the reason phrase between its position and limit
  • Method Details

    • of

      public static Frame.ConnectionClose of(long errorCode, long frameType, String reason)
      A transport CONNECTION_CLOSE frame with a text reason.
      Parameters:
      errorCode - the transport error code
      frameType - the type of the offending frame, or 0
      reason - the reason phrase
      Returns:
      the frame
    • reason

      public ByteBuffer reason()
      The reason phrase.
      Returns:
      an independent view of the reason bytes
    • reasonPhrase

      public String reasonPhrase()
      The reason phrase as text.
      Returns:
      the reason decoded as UTF-8, with malformed bytes replaced
    • encode

      public boolean encode(ByteBuffer out, int budget)
      Writes the frame, truncating the reason phrase to fit a byte budget, as quinn does.
      Parameters:
      out - the buffer, written at its position
      budget - the most bytes the frame may take (also bounded by out.remaining())
      Returns:
      false if not even an empty reason fits, in which case nothing is written
    • type

      public FrameType type()
      Description copied from interface: Frame
      The frame type.
      Specified by:
      type in interface Frame
      Returns:
      the type
    • typeCode

      public long typeCode()
      Description copied from interface: Frame
      The exact type code this frame encodes with, flags included.
      Specified by:
      typeCode in interface Frame
      Returns:
      the type code
    • encodedLength

      public int encodedLength()
      Description copied from interface: Frame
      The encoded length.
      Specified by:
      encodedLength in interface Frame
      Returns:
      the bytes Frame.encode(java.nio.ByteBuffer) writes
    • encode

      public void encode(ByteBuffer out)
      Description copied from interface: Frame
      Writes the frame at the buffer's position.
      Specified by:
      encode in interface Frame
      Parameters:
      out - the buffer
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • errorCode

      public long errorCode()
      Returns the value of the errorCode record component.
      Returns:
      the value of the errorCode record component
    • frameType

      public long frameType()
      Returns the value of the frameType record component.
      Returns:
      the value of the frameType record component