org.java_websocket.drafts
Class Draft

java.lang.Object
  extended by org.java_websocket.drafts.Draft
Direct Known Subclasses:
Draft_10, Draft_75

public abstract class Draft
extends Object

Base class for everything of a websocket specification which is not common such as the way the handshake is read or frames are transfered.


Nested Class Summary
static class Draft.CloseHandshakeType
           
static class Draft.HandshakeState
           
 
Field Summary
static byte[] FLASH_POLICY_REQUEST
           
static int INITIAL_FAMESIZE
           
static int MAX_FAME_SIZE
           
protected  WebSocket.Role role
          In some cases the handshake will be parsed different depending on whether
 
Constructor Summary
Draft()
           
 
Method Summary
abstract  Draft.HandshakeState acceptHandshakeAsClient(ClientHandshake request, ServerHandshake response)
           
abstract  Draft.HandshakeState acceptHandshakeAsServer(ClientHandshake handshakedata)
           
protected  boolean basicAccept(Handshakedata handshakedata)
           
 int checkAlloc(int bytecount)
           
abstract  Draft copyInstance()
          Drafts must only be by one websocket at all.
abstract  ByteBuffer createBinaryFrame(Framedata framedata)
           
abstract  List<Framedata> createFrames(ByteBuffer binary, boolean mask)
           
abstract  List<Framedata> createFrames(String text, boolean mask)
           
 List<ByteBuffer> createHandshake(Handshakedata handshakedata, WebSocket.Role ownrole)
           
 List<ByteBuffer> createHandshake(Handshakedata handshakedata, WebSocket.Role ownrole, boolean withcontent)
           
abstract  Draft.CloseHandshakeType getCloseHandshakeType()
           
abstract  ClientHandshakeBuilder postProcessHandshakeRequestAsClient(ClientHandshakeBuilder request)
           
abstract  HandshakeBuilder postProcessHandshakeResponseAsServer(ClientHandshake request, ServerHandshakeBuilder response)
           
static ByteBuffer readLine(ByteBuffer buf)
           
static String readStringLine(ByteBuffer buf)
           
abstract  void reset()
           
 void setParseMode(WebSocket.Role role)
           
abstract  List<Framedata> translateFrame(ByteBuffer buffer)
           
 Handshakedata translateHandshake(ByteBuffer buf)
           
static HandshakeBuilder translateHandshakeHttp(ByteBuffer buf, WebSocket.Role role)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_FAME_SIZE

public static int MAX_FAME_SIZE

INITIAL_FAMESIZE

public static int INITIAL_FAMESIZE

FLASH_POLICY_REQUEST

public static final byte[] FLASH_POLICY_REQUEST

role

protected WebSocket.Role role
In some cases the handshake will be parsed different depending on whether

Constructor Detail

Draft

public Draft()
Method Detail

readLine

public static ByteBuffer readLine(ByteBuffer buf)

readStringLine

public static String readStringLine(ByteBuffer buf)

translateHandshakeHttp

public static HandshakeBuilder translateHandshakeHttp(ByteBuffer buf,
                                                      WebSocket.Role role)
                                               throws InvalidHandshakeException,
                                                      IncompleteHandshakeException
Throws:
InvalidHandshakeException
IncompleteHandshakeException

acceptHandshakeAsClient

public abstract Draft.HandshakeState acceptHandshakeAsClient(ClientHandshake request,
                                                             ServerHandshake response)
                                                      throws InvalidHandshakeException
Throws:
InvalidHandshakeException

acceptHandshakeAsServer

public abstract Draft.HandshakeState acceptHandshakeAsServer(ClientHandshake handshakedata)
                                                      throws InvalidHandshakeException
Throws:
InvalidHandshakeException

basicAccept

protected boolean basicAccept(Handshakedata handshakedata)

createBinaryFrame

public abstract ByteBuffer createBinaryFrame(Framedata framedata)

createFrames

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

createFrames

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

reset

public abstract void reset()

createHandshake

public List<ByteBuffer> createHandshake(Handshakedata handshakedata,
                                        WebSocket.Role ownrole)

createHandshake

public List<ByteBuffer> createHandshake(Handshakedata handshakedata,
                                        WebSocket.Role ownrole,
                                        boolean withcontent)

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

public abstract List<Framedata> translateFrame(ByteBuffer buffer)
                                        throws InvalidDataException
Throws:
InvalidDataException

getCloseHandshakeType

public abstract Draft.CloseHandshakeType getCloseHandshakeType()

copyInstance

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.


translateHandshake

public Handshakedata translateHandshake(ByteBuffer buf)
                                 throws InvalidHandshakeException
Throws:
InvalidHandshakeException

checkAlloc

public int checkAlloc(int bytecount)
               throws LimitExedeedException,
                      InvalidDataException
Throws:
LimitExedeedException
InvalidDataException

setParseMode

public void setParseMode(WebSocket.Role role)


Copyright © 2013 Pusher. All Rights Reserved.