Class CloseStatus

java.lang.Object
org.eclipse.jetty.websocket.core.CloseStatus

public class CloseStatus extends Object
Representation of a WebSocket Close (status code & reason)
  • Field Details

  • Constructor Details

    • CloseStatus

      public CloseStatus()
      Creates a reason for closing a web socket connection with the no given status code.
    • CloseStatus

      public CloseStatus(int statusCode)
      Creates a reason for closing a web socket connection with the given status code and no reason phrase.
      Parameters:
      statusCode - the close code
    • CloseStatus

      public CloseStatus(int statusCode, String reasonPhrase)
      Creates a reason for closing a web socket connection with the given status code and reason phrase.
      Parameters:
      statusCode - the close code
      reasonPhrase - the reason phrase
    • CloseStatus

      public CloseStatus(int statusCode, Throwable cause)
      Creates a reason for closing a web socket connection with the given status code and reason phrase.
      Parameters:
      statusCode - the close code
      cause - the error which caused the close
    • CloseStatus

      public CloseStatus(int statusCode, String reasonPhrase, Throwable cause)
      Creates a reason for closing a web socket connection with the given status code and reason phrase.
      Parameters:
      statusCode - the close code
      reasonPhrase - the reason phrase
      cause - the error which caused the close
    • CloseStatus

      public CloseStatus(Frame frame)
    • CloseStatus

      public CloseStatus(ByteBuffer payload)
  • Method Details

    • getCloseStatus

      public static CloseStatus getCloseStatus(Frame frame)
    • isOrdinary

      public static boolean isOrdinary(int closeCode)
    • isAbnormal

      public boolean isAbnormal()
    • getCause

      public Throwable getCause()
    • getCode

      public int getCode()
    • getReason

      public String getReason()
    • asPayloadBuffer

      public ByteBuffer asPayloadBuffer()
    • asPayloadBuffer

      public static ByteBuffer asPayloadBuffer(int statusCode, String reason)
    • isTransmittableStatusCode

      public static boolean isTransmittableStatusCode(int statusCode)
      Test if provided status code can be sent/received on a WebSocket close.

      This honors the RFC6455 rules and IANA rules.

      Parameters:
      statusCode - the statusCode to test
      Returns:
      true if transmittable
    • toFrame

      public Frame toFrame()
    • toFrame

      public static Frame toFrame(int closeStatus)
    • toFrame

      public static Frame toFrame(int closeStatus, String reason)
    • codeString

      public static String codeString(int closeStatus)
    • isNormal

      public boolean isNormal()
    • toString

      public String toString()
      Overrides:
      toString in class Object