Package org.glassfish.tyrus.core.frame
Class Frame
- java.lang.Object
-
- org.glassfish.tyrus.core.frame.Frame
-
- Direct Known Subclasses:
TyrusFrame
public class Frame extends java.lang.Object
WebSocket frame representation.TODO: - masking (isMask is currently ignored) - validation - payloadLength is limited to int
- Author:
- Pavel Bucek (pavel.bucek at oracle.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Frame.Builder
Frame builder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Frame.Builder
builder()
Create newFrame.Builder
.static Frame.Builder
builder(Frame frame)
Create newFrame.Builder
based on provided frame.java.lang.Integer
getMaskingKey()
Get masking key.byte
getOpcode()
Get opcode.byte[]
getPayloadData()
Get payload data.long
getPayloadLength()
Get payload length.boolean
isControlFrame()
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.java.lang.String
toString()
-
-
-
Constructor Detail
-
Frame
protected Frame(Frame frame)
Copy constructor.Note: this is shallow copy. Payload is *not* copied to new array.
- Parameters:
frame
- copied frame.
-
-
Method Detail
-
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
public java.lang.Integer 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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
builder
public static Frame.Builder builder()
Create newFrame.Builder
.- Returns:
- new builder instance.
-
builder
public static Frame.Builder builder(Frame frame)
Create newFrame.Builder
based on provided frame.- Parameters:
frame
- frame used as a base for building new frame.- Returns:
- new builder instance.
-
-