Package ej.websocket
Class ReasonForClosure
- java.lang.Object
-
- ej.websocket.ReasonForClosure
-
public final class ReasonForClosure extends Object
AReasonForClosureis a close code (which is a number) and a close reason (which a String that may be empty).As explained in section 7.4. Status Codes, "an endpoint may indicate a reason for closure" when sending a close frame. If it does so, the reason for closure is composed of two parts (section 5.5.1 Close):
- 'status code' (section 7.4) or 'close code' (section 7.1.5), which is a 2-byte unsigned integer,
- 'close reason' (section 7.1.6), which may be empty.
- empty (no close code, no close reason),
- 2-byte long (close code, but no close reason),
- more than 2-byte long (close code, close reason).
- See Also:
CloseCodes
-
-
Constructor Summary
Constructors Constructor Description ReasonForClosure(int code, String reason)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCloseCode()Get the close code.StringgetCloseReason()Get the close reason (may be an empty string).ReasonForClosuresetCode(int code)Change the close code.ReasonForClosuresetReason(String reason)Change the close reason.StringtoString()Returns a string representation of the object.
-
-
-
Constructor Detail
-
ReasonForClosure
public ReasonForClosure(int code, String reason)- Parameters:
code- the close codereason- a message that describes why the connection has been closed. It may be empty. If it is null, it is converted to the empty string.- See Also:
CloseCodes
-
-
Method Detail
-
getCloseCode
public int getCloseCode()
Get the close code.- Returns:
- the close code
-
setCode
public ReasonForClosure setCode(int code)
Change the close code.- Parameters:
code- the new code- Returns:
- this
-
getCloseReason
public String getCloseReason()
Get the close reason (may be an empty string).- Returns:
- a message that describes why the connection has been closed
-
setReason
public ReasonForClosure setReason(String reason)
Change the close reason.- Parameters:
reason- the new reason message. It may be empty. If it is null, it is converted to the empty string.- Returns:
- this
-
toString
public String toString()
Description copied from class:ObjectReturns a string representation of the object. In general, thetoStringmethod returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.The
toStringmethod for classObjectreturns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:getClass().getName() + '@' + Integer.toHexString(hashCode())
-
-