Package org.glassfish.tyrus.core.frame
Class Frame
java.lang.Object
org.glassfish.tyrus.core.frame.Frame
- Direct Known Subclasses:
TyrusFrame
WebSocket frame representation.
TODO: - masking (isMask is currently ignored) - validation - payloadLength is limited to int
- Author:
- Pavel Bucek
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Frame.Builder
builder()
Create newFrame.Builder
.static Frame.Builder
Create newFrame.Builder
based on provided frame.Get masking key.byte
Get opcode.byte[]
Get payload data.long
Get payload length.boolean
Get information about frame type.boolean
isFin()
Get FIN value.boolean
isMask()
Currently not used.boolean
isRsv1()
GET RSV1 value.boolean
isRsv2()
GET RSV2 value.boolean
isRsv3()
GET RSV3 value.toString()
-
Constructor Details
-
Frame
Copy constructor.Note: this is shallow copy. Payload is *not* copied to new array.
- Parameters:
frame
- copied frame.
-
-
Method Details
-
isFin
public boolean isFin()Get FIN value.- Returns:
true
when FIN flag is set,false
otherwise.
-
isRsv1
public boolean isRsv1()GET RSV1 value.- Returns:
true
when RSV1 flag is set,false
otherwise.
-
isRsv2
public boolean isRsv2()GET RSV2 value.- Returns:
true
when RSV2 flag is set,false
otherwise.
-
isRsv3
public boolean isRsv3()GET RSV3 value.- Returns:
true
when RSV3 flag is set,false
otherwise.
-
isMask
public boolean isMask()Currently not used.- Returns:
- not used.
-
getOpcode
public byte getOpcode()Get opcode.- Returns:
- opcode (4 bit value).
-
getPayloadLength
public long getPayloadLength()Get payload length.- Returns:
- payload length.
-
getMaskingKey
Get masking key.- Returns:
- masking key (32 bit value) or
null
when the frame should not be masked.
-
getPayloadData
public byte[] getPayloadData()Get payload data.Changes done to returned array won't be propagated to current
Frame
instance. If you need to modify payload, you have to create new instance, seeBuilder#Frame(Frame)
. Length of returned array will be always same asgetPayloadLength()
.- Returns:
- payload data.
-
isControlFrame
public boolean isControlFrame()Get information about frame type.- Returns:
true
when this frame is control (close, ping, pong) frame,false
otherwise.
-
toString
-
builder
Create newFrame.Builder
.- Returns:
- new builder instance.
-
builder
Create newFrame.Builder
based on provided frame.- Parameters:
frame
- frame used as a base for building new frame.- Returns:
- new builder instance.
-