Class Reason


  • public class Reason
    extends java.lang.Object
    The Reason object is used to hold a textual reason for connection closure and an RFC 6455 defined code. When a connection is to be closed a control frame with an opcode of close is sent with the text reason, if one is provided.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private CloseCode code
      This is the close code to be sent with a control frame.
      private java.lang.String text
      This is the textual description of the close reason.
    • Constructor Summary

      Constructors 
      Constructor Description
      Reason​(CloseCode code)
      Constructor for the Reason object.
      Reason​(CloseCode code, java.lang.String text)
      Constructor for the Reason object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      CloseCode getCode()
      This is used to get the RFC 6455 code describing the type of close event.
      java.lang.String getText()
      This is used to get the textual description for the closure.
      java.lang.String toString()
      This is used to provide a textual representation of the reason.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • code

        private final CloseCode code
        This is the close code to be sent with a control frame.
      • text

        private final java.lang.String text
        This is the textual description of the close reason.
    • Constructor Detail

      • Reason

        public Reason​(CloseCode code)
        Constructor for the Reason object. This is used to create a reason and a textual description of that reason to be delivered as a control frame.
        Parameters:
        code - this is the code to be sent with the frame
      • Reason

        public Reason​(CloseCode code,
                      java.lang.String text)
        Constructor for the Reason object. This is used to create a reason and a textual description of that reason to be delivered as a control frame.
        Parameters:
        code - this is the code to be sent with the frame
        text - this is textual description of the close reason
    • Method Detail

      • getCode

        public CloseCode getCode()
        This is used to get the RFC 6455 code describing the type of close event. It is the code that should be used by applications to determine why the connection was terminated.
        Returns:
        returns the close code for the connection
      • getText

        public java.lang.String getText()
        This is used to get the textual description for the closure. In many scenarios there will be no textual reason as it is an optional attribute.
        Returns:
        this returns the description for the closure
      • toString

        public java.lang.String toString()
        This is used to provide a textual representation of the reason. For consistency this will only return the enumerated value for the close code, or if none exists a "null" text string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        this returns a string representation of the reason