Skip to content
Marcel Prestel edited this page Jul 26, 2017 · 20 revisions

Overview

Frames can be parts or all of a text or binary data message that is sent from a client or server. This package contains classes that provide the websocket frame implementation.

TextFrame

This class is an implementation of a frame specified by section 5.6 and is a specific implementation of a DataFrame.

This frame should be used if the "Payload data" is text data encoded as UTF-8.

This frame is valid if the payload is a valid UTF-8 sequence.

BinaryFrame

This class is an implementation of a frame specified by section 5.6 and is a specific implementation of a DataFrame. This frame is should be used if the "Payload data" is arbitrary binary data whose interpretation is solely up to the application layer.

There are no currently no specific validations implemented for this frame.

ContinuousFrame

This class is an implementation of a frame specified by section 5.2 and is a specific implementation of a Dataframe. This class is mostly used internally for fragmented frames.

There are no currently no specific validations implemented for this frame.

CloseFrame

This class is an implementation of a frame specified by section 5.5.1 and is a specific implementation of a ControlFrame. This class is mostly used internally for handling the closing of a connection.

This frame is valid, if the close code as well as the reason is valid.

PingFrame

This class is an implementation of a frame specified by section 5.5.2 and is a specific implementation of a ControlFrame.

There are no currently no specific validations implemented for this frame.

PongFrame

This class is an implementation of a frame specified by section 5.5.3 and is a specific implementation of a ControlFrame. It contains an additional constructor to create a response for a PingFrame.

There are no currently no specific validations implemented for this frame.

ControlFrame

This class is a general implementation of a frame specified by section 5.5.

This frame is valid, if FIN as well as RSV1, RSV2 and RSV3 is not set (so false).

DataFrame

This class is a general implementation of a frame specified by section 5.6.

There are no currently no specific validations implemented for this frame.

Framedata

This interface provides the layout of a frame.

isFin() represents the first bit in the frame which marks the frame as the final or non-final frame of a message. Messages are made up of one or more frames.

isRSV1() represents the second bit in the frame which marks the frame as part of an specific extension.

isRSV2() represents the third bit in the frame which marks the frame as part of an specific extension.

isRSV3() represents the forth bit in the frame which marks the frame as part of an specific extension.

getTransferredMasked() is the 8th bit in the frame and is used to determine if the clients payload is masked. Masking payloads is used to prevent proxy cache poisoning attacks. The 32-bit value taken from the frame header that masks the payload is placed between bits 48-80.

getOpcode() are bits 3-7 and is used to determine the type of data that the frame is sending. 0 - Continuation Frame 1 - Text Frame 2- Binary Frame 8 - Connection Close Frame 9 - Ping Frame 10 - Pong Frame

Missing Method it is recommended that a new method be introduced to identify payload length. Draft_10 already has payload length inside translateSingleFrame method. Payload length utilises bits 9-15. If payload length is 0-125 then the method should return the length. If the payload length is 126 then the method should read the following 16 bits and return the 16-bit unsigned integer they contain. If the payload length is 127 then the method should read the following 64 bits and return the 64-bit unsigned integer they contain.

getPayloadData() is used to get the payload data from bit 80 onwards.

append( Framedata nextframe ) is used to append another frame to the message. The maximum size for a single frame is 18,446,744,073,709,551,615 bytes but each frame implementation can handle this differently.

FramedataImpl1

This class implements all the methods specified by the interface Framedata and provides also setters for these values.

It also implements a static method to get a specific frame for a supplied opcode. E.g.:

FramedataImpl1.get(Opcode.BINARY) // This will return a BinaryFrame