com.caucho.remote.websocket
Class FrameInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.caucho.remote.websocket.FrameInputStream
All Implemented Interfaces:
WebSocketConstants, java.io.Closeable
Direct Known Subclasses:
MaskedFrameInputStream, UnmaskedFrameInputStream

public abstract class FrameInputStream
extends java.io.InputStream
implements WebSocketConstants

WebSocketInputStream reads a single WebSocket packet.

 +-+------+---------+-+---------+
 |F|xxx(3)|opcode(4)|R|len(7)   |
 +-+------+---------+-+---------+
 
 OPCODES
   0 - cont
   1 - close
   2 - ping
   3 - pong
   4 - text
   5 - binary
 


Field Summary
 
Fields inherited from interface com.caucho.remote.websocket.WebSocketConstants
CLOSE_ERROR, CLOSE_MESSAGE_TOO_BIG, CLOSE_OK, CLOSE_UTF8, FLAG_FIN, FLAG_MASK, MASK_OPCODE, OP_BINARY, OP_CLOSE, OP_CONT, OP_PING, OP_PONG, OP_TEXT, VERSION
 
Constructor Summary
FrameInputStream()
           
 
Method Summary
 void closeError(int i, java.lang.String msg)
           
 WebSocketContext getContext()
           
abstract  long getLength()
           
abstract  int getOpcode()
           
protected  boolean handleFrame()
           
 void init(WebSocketContext cxt, java.io.InputStream is)
           
 WebSocketReader initReader(long length, boolean isFinal)
           
abstract  boolean isFinal()
           
 boolean readFrameHeader()
           
protected abstract  boolean readFrameHeaderImpl()
           
 void skipToFrameEnd()
           
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FrameInputStream

public FrameInputStream()
Method Detail

init

public void init(WebSocketContext cxt,
                 java.io.InputStream is)

getContext

public WebSocketContext getContext()

getOpcode

public abstract int getOpcode()

getLength

public abstract long getLength()

isFinal

public abstract boolean isFinal()

initReader

public WebSocketReader initReader(long length,
                                  boolean isFinal)
                           throws java.io.IOException
Throws:
java.io.IOException

readFrameHeader

public boolean readFrameHeader()
                        throws java.io.IOException
Throws:
java.io.IOException

readFrameHeaderImpl

protected abstract boolean readFrameHeaderImpl()
                                        throws java.io.IOException
Throws:
java.io.IOException

handleFrame

protected boolean handleFrame()
                       throws java.io.IOException
Throws:
java.io.IOException

skipToFrameEnd

public void skipToFrameEnd()
                    throws java.io.IOException
Throws:
java.io.IOException

closeError

public void closeError(int i,
                       java.lang.String msg)