Top Description Fields Constructors Methods
org.java_websocket.drafts

public abstract Class Draft

extends Object
Class Inheritance
Known Direct Subclasses
org.java_websocket.drafts.Draft_6455
Imports
java.nio.ByteBuffer, java.util.Collections, .Iterator, .List, .Locale, org.java_websocket.WebSocketImpl, org.java_websocket.enums.CloseHandshakeType, .HandshakeState, .Opcode, .Role, org.java_websocket.exceptions.IncompleteHandshakeException, .InvalidDataException, .InvalidHandshakeException, org.java_websocket.framing.BinaryFrame, .CloseFrame, .ContinuousFrame, .DataFrame, .Framedata, .TextFrame, org.java_websocket.handshake.ClientHandshake, .ClientHandshakeBuilder, .HandshakeBuilder, .HandshakeImpl1Client, .HandshakeImpl1Server, .Handshakedata, .ServerHandshake, .ServerHandshakeBuilder, org.java_websocket.util.Charsetfunctions

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

Modifier and TypeField and Description
protected Opcode
protected Role
role

In some cases the handshake will be parsed different depending on whether

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract HandshakeState
public abstract HandshakeState
protected boolean
basicAccept(Handshakedata handshakedata)

public int
checkAlloc(int bytecount)

public List<Framedata>
continuousFrame(Opcode op, ByteBuffer buffer, boolean fin)

public abstract Draft

Returns:

a copy of the draft
copyInstance
()

Drafts must only be by one websocket at all.

public abstract ByteBuffer
public abstract List<Framedata>
createFrames(ByteBuffer binary, boolean mask)

public abstract List<Framedata>
createFrames(String text, boolean mask)

public List<ByteBuffer>
createHandshake(Handshakedata handshakedata, Role ownrole)
Deprecated use createHandshake without the role

public List<ByteBuffer>
public List<ByteBuffer>
createHandshake(Handshakedata handshakedata, Role ownrole, boolean withcontent)
Deprecated use createHandshake without the role since it does not have any effect

public List<ByteBuffer>
createHandshake(Handshakedata handshakedata, boolean withcontent)

public abstract CloseHandshakeType
public Role
public abstract ClientHandshakeBuilder
public abstract HandshakeBuilder
public abstract void
processFrame(WebSocketImpl
the websocketimpl used for this draft
webSocketImpl
,
Framedata
the frame which is supposed to be handled
frame
)

Handle the frame specific to the draft

public static ByteBuffer
public static String
pack-priv int
readVersion(Handshakedata handshakedata)

public abstract void
public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public abstract List<Framedata>
public Handshakedata
public static HandshakeBuilder
private static HandshakeBuilder

Returns:

a handshake
translateHandshakeHttpClient
(String[]
the token of the first line split as as an string array
firstLineTokens
,
String
the whole line
line
)

Checking the handshake for the role as client

private static HandshakeBuilder

Returns:

a handshake
translateHandshakeHttpServer
(String[]
the token of the first line split as as an string array
firstLineTokens
,
String
the whole line
line
)

Checking the handshake for the role as server

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

continuousFrameTypeback to summary
protected Opcode continuousFrameType
roleback to summary
protected Role role

In some cases the handshake will be parsed different depending on whether

Constructor Detail

Draftback to summary
public Draft()

Method Detail

acceptHandshakeAsClientback to summary
public abstract HandshakeState acceptHandshakeAsClient(ClientHandshake request, ServerHandshake response) throws InvalidHandshakeException
acceptHandshakeAsServerback to summary
public abstract HandshakeState acceptHandshakeAsServer(ClientHandshake handshakedata) throws InvalidHandshakeException
basicAcceptback to summary
protected boolean basicAccept(Handshakedata handshakedata)
checkAllocback to summary
public int checkAlloc(int bytecount) throws InvalidDataException
continuousFrameback to summary
public List<Framedata> continuousFrame(Opcode op, ByteBuffer buffer, boolean fin)
copyInstanceback to summary
public abstract Draft 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:Draft

a copy of the draft

createBinaryFrameback to summary
public abstract ByteBuffer createBinaryFrame(Framedata framedata)
createFramesback to summary
public abstract List<Framedata> createFrames(ByteBuffer binary, boolean mask)
createFramesback to summary
public abstract List<Framedata> createFrames(String text, boolean mask)
createHandshakeback to summary
public List<ByteBuffer> createHandshake(Handshakedata handshakedata, Role ownrole)

Deprecated

use createHandshake without the role

Annotations
@Deprecated
createHandshakeback to summary
public List<ByteBuffer> createHandshake(Handshakedata handshakedata)
createHandshakeback to summary
public List<ByteBuffer> createHandshake(Handshakedata handshakedata, Role ownrole, boolean withcontent)

Deprecated

use createHandshake without the role since it does not have any effect

Annotations
@Deprecated
createHandshakeback to summary
public List<ByteBuffer> createHandshake(Handshakedata handshakedata, boolean withcontent)
getCloseHandshakeTypeback to summary
public abstract CloseHandshakeType getCloseHandshakeType()
getRoleback to summary
public Role getRole()
postProcessHandshakeRequestAsClientback to summary
public abstract ClientHandshakeBuilder postProcessHandshakeRequestAsClient(ClientHandshakeBuilder request) throws InvalidHandshakeException
postProcessHandshakeResponseAsServerback to summary
public abstract HandshakeBuilder postProcessHandshakeResponseAsServer(ClientHandshake request, ServerHandshakeBuilder response) throws InvalidHandshakeException
processFrameback to summary
public abstract void processFrame(WebSocketImpl webSocketImpl, Framedata frame) throws InvalidDataException

Handle the frame specific to the draft

Parameters
webSocketImpl:WebSocketImpl

the websocketimpl used for this draft

frame:Framedata

the frame which is supposed to be handled

Exceptions
InvalidDataException:
will be thrown on invalid data
readLineback to summary
public static ByteBuffer readLine(ByteBuffer buf)
readStringLineback to summary
public static String readStringLine(ByteBuffer buf)
readVersionback to summary
pack-priv int readVersion(Handshakedata handshakedata)
resetback to summary
public abstract void reset()
setParseModeback to summary
public void setParseMode(Role role)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

translateFrameback to summary
public abstract List<Framedata> translateFrame(ByteBuffer buffer) throws InvalidDataException
translateHandshakeback to summary
public Handshakedata translateHandshake(ByteBuffer buf) throws InvalidHandshakeException
translateHandshakeHttpback to summary
public static HandshakeBuilder translateHandshakeHttp(ByteBuffer buf, Role role) throws InvalidHandshakeException
translateHandshakeHttpClientback to summary
private static HandshakeBuilder translateHandshakeHttpClient(String[] firstLineTokens, String line) throws InvalidHandshakeException

Checking the handshake for the role as client

Parameters
firstLineTokens:String[]

the token of the first line split as as an string array

line:String

the whole line

Returns:HandshakeBuilder

a handshake

translateHandshakeHttpServerback to summary
private static HandshakeBuilder translateHandshakeHttpServer(String[] firstLineTokens, String line) throws InvalidHandshakeException

Checking the handshake for the role as server

Parameters
firstLineTokens:String[]

the token of the first line split as as an string array

line:String

the whole line

Returns:HandshakeBuilder

a handshake