Package org.java_websocket.drafts
Class Draft
java.lang.Object
org.java_websocket.drafts.Draft
- Direct Known Subclasses:
Draft_6455
Base class for everything of a websocket specification which is not common such as the way the
handshake is read or frames are transferred.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract HandshakeState
acceptHandshakeAsClient
(ClientHandshake request, ServerHandshake response) abstract HandshakeState
acceptHandshakeAsServer
(ClientHandshake handshakedata) protected boolean
basicAccept
(Handshakedata handshakedata) int
checkAlloc
(int bytecount) continuousFrame
(Opcode op, ByteBuffer buffer, boolean fin) abstract Draft
Drafts must only be by one websocket at all.abstract ByteBuffer
createBinaryFrame
(Framedata framedata) createFrames
(String text, boolean mask) createFrames
(ByteBuffer binary, boolean mask) createHandshake
(Handshakedata handshakedata) createHandshake
(Handshakedata handshakedata, boolean withcontent) createHandshake
(Handshakedata handshakedata, Role ownrole) Deprecated.use createHandshake without the rolecreateHandshake
(Handshakedata handshakedata, Role ownrole, boolean withcontent) Deprecated.use createHandshake without the role since it does not have any effectabstract CloseHandshakeType
getRole()
abstract ClientHandshakeBuilder
abstract HandshakeBuilder
postProcessHandshakeResponseAsServer
(ClientHandshake request, ServerHandshakeBuilder response) abstract void
processFrame
(WebSocketImpl webSocketImpl, Framedata frame) Handle the frame specific to the draftstatic ByteBuffer
readLine
(ByteBuffer buf) static String
readStringLine
(ByteBuffer buf) abstract void
reset()
void
setParseMode
(Role role) toString()
translateFrame
(ByteBuffer buffer) static HandshakeBuilder
translateHandshakeHttp
(ByteBuffer buf, Role role)
-
Field Details
-
role
In some cases the handshake will be parsed different depending on whether -
continuousFrameType
-
-
Constructor Details
-
Draft
public Draft()
-
-
Method Details
-
readLine
-
readStringLine
-
translateHandshakeHttp
public static HandshakeBuilder translateHandshakeHttp(ByteBuffer buf, Role role) throws InvalidHandshakeException - Throws:
InvalidHandshakeException
-
acceptHandshakeAsClient
public abstract HandshakeState acceptHandshakeAsClient(ClientHandshake request, ServerHandshake response) throws InvalidHandshakeException - Throws:
InvalidHandshakeException
-
acceptHandshakeAsServer
public abstract HandshakeState acceptHandshakeAsServer(ClientHandshake handshakedata) throws InvalidHandshakeException - Throws:
InvalidHandshakeException
-
basicAccept
-
createBinaryFrame
-
createFrames
-
createFrames
-
processFrame
public abstract void processFrame(WebSocketImpl webSocketImpl, Framedata frame) throws InvalidDataException Handle the frame specific to the draft- Parameters:
webSocketImpl
- the websocketimpl used for this draftframe
- the frame which is supposed to be handled- Throws:
InvalidDataException
- will be thrown on invalid data
-
continuousFrame
-
reset
public abstract void reset() -
createHandshake
Deprecated.use createHandshake without the role -
createHandshake
-
createHandshake
@Deprecated public List<ByteBuffer> createHandshake(Handshakedata handshakedata, Role ownrole, boolean withcontent) Deprecated.use createHandshake without the role since it does not have any effect -
createHandshake
-
postProcessHandshakeRequestAsClient
public abstract ClientHandshakeBuilder postProcessHandshakeRequestAsClient(ClientHandshakeBuilder request) throws InvalidHandshakeException - Throws:
InvalidHandshakeException
-
postProcessHandshakeResponseAsServer
public abstract HandshakeBuilder postProcessHandshakeResponseAsServer(ClientHandshake request, ServerHandshakeBuilder response) throws InvalidHandshakeException - Throws:
InvalidHandshakeException
-
translateFrame
- Throws:
InvalidDataException
-
getCloseHandshakeType
-
copyInstance
Drafts must only be by one websocket at all. To prevent drafts to be used more than once the Websocket implementation should call this method in order to create a new usable version of a given draft instance.
The copy can be safely used in conjunction with a new websocket connection.- Returns:
- a copy of the draft
-
translateHandshake
- Throws:
InvalidHandshakeException
-
checkAlloc
- Throws:
InvalidDataException
-
setParseMode
-
getRole
-
toString
-