Class ReasonExtractor
- java.lang.Object
-
- org.simpleframework.http.socket.service.ReasonExtractor
-
class ReasonExtractor extends java.lang.Object
TheReasonExtractor
object is used to extract the close reason from a frame payload. If their is no close reason this will return aReason
with just the close code. Finally in the event of a botched frame being sent with no close code then the close code 1005 is used to indicate no reason.
-
-
Field Summary
Fields Modifier and Type Field Description private DataConverter
converter
This is the data converter object used to convert data.
-
Constructor Summary
Constructors Constructor Description ReasonExtractor()
Constructor for theReasonExtractor
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Reason
extract(Frame frame)
This is used to extract a reason from the provided frame.private CloseCode
extractCode(byte[] data)
This method is used to extract the close code.private java.lang.String
extractText(byte[] data)
This method is used to extract the UTF-8 description from the frame payload.
-
-
-
Field Detail
-
converter
private final DataConverter converter
This is the data converter object used to convert data.
-
-
Method Detail
-
extract
public Reason extract(Frame frame)
This is used to extract a reason from the provided frame. The close reason is taken from the first two bytes of the frame payload and the UTF-8 string that follows is the description.- Parameters:
frame
- this is the frame to extract the reason from- Returns:
- a reason containing the close code and reason
-
extractText
private java.lang.String extractText(byte[] data)
This method is used to extract the UTF-8 description from the frame payload. If there are only two bytes within the payload then this will return null for the reason.- Parameters:
data
- the frame payload to extract the description from- Returns:
- returns the description within the payload
-
extractCode
private CloseCode extractCode(byte[] data)
This method is used to extract the close code. The close code is an two byte integer in network byte order at the start of the close frame payload. This code is required by RFC 6455 however if not code is available code 1005 is returned.- Parameters:
data
- the frame payload to extract the description from- Returns:
- returns the description within the payload
-
-