com.caucho.remote.websocket
Class WebSocketContextStreamImpl

java.lang.Object
  extended by com.caucho.remote.websocket.WebSocketContextStreamImpl
All Implemented Interfaces:
WebSocketConstants, WebSocketContext

public class WebSocketContextStreamImpl
extends java.lang.Object
implements WebSocketContext, WebSocketConstants

User facade for http requests.


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
WebSocketContextStreamImpl(WriteStream out)
           
 
Method Summary
 void close()
          gracefully close the connection, waiting for unread messages.
 void close(int code, java.lang.String msg)
          gracefully close the connection, waiting for unread messages.
<T> java.util.concurrent.BlockingQueue<T>
createOutputQueue(WebSocketEncoder<T> encoder)
          Creates a thread-safe queue, which applications can send objects to be marshaled.
protected  WebSocketInputStream createWebSocketInputStream(FrameInputStream is)
           
 void disconnect()
          Disconnect the connection.
 void flush()
          flushes the output stream
 long getTimeout()
          Gets the read timeout.
protected  WriteStream getWriteStream()
           
 boolean isAutoFlush()
          returns the current flush mode.
 void onClose(int closeCode, java.lang.String closeMessage)
           
 void pong(byte[] bytes)
          sends a pong message
 void setAutoFlush(boolean isAutoFlush)
          auto-flush after each message is sent.
 void setTimeout(long timeout)
          Sets the read timeout.
 java.io.OutputStream startBinaryMessage()
          Returns the output stream for a binary message.
 java.io.PrintWriter startTextMessage()
          Returns the output stream for a binary message.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebSocketContextStreamImpl

public WebSocketContextStreamImpl(WriteStream out)
Method Detail

setTimeout

public void setTimeout(long timeout)
Description copied from interface: WebSocketContext
Sets the read timeout.

Specified by:
setTimeout in interface WebSocketContext

getTimeout

public long getTimeout()
Description copied from interface: WebSocketContext
Gets the read timeout.

Specified by:
getTimeout in interface WebSocketContext

startBinaryMessage

public java.io.OutputStream startBinaryMessage()
                                        throws java.io.IOException
Description copied from interface: WebSocketContext
Returns the output stream for a binary message. The message will complete when the OutputStream is closed.

Specified by:
startBinaryMessage in interface WebSocketContext
Throws:
java.io.IOException

startTextMessage

public java.io.PrintWriter startTextMessage()
                                     throws java.io.IOException
Description copied from interface: WebSocketContext
Returns the output stream for a binary message. The message will complete when the Writer is closed.

Specified by:
startTextMessage in interface WebSocketContext
Throws:
java.io.IOException

pong

public void pong(byte[] bytes)
Description copied from interface: WebSocketContext
sends a pong message

Specified by:
pong in interface WebSocketContext

close

public void close()
Description copied from interface: WebSocketContext
gracefully close the connection, waiting for unread messages.

Specified by:
close in interface WebSocketContext

close

public void close(int code,
                  java.lang.String msg)
Description copied from interface: WebSocketContext
gracefully close the connection, waiting for unread messages.

Specified by:
close in interface WebSocketContext

getWriteStream

protected WriteStream getWriteStream()

disconnect

public void disconnect()
Description copied from interface: WebSocketContext
Disconnect the connection.

Specified by:
disconnect in interface WebSocketContext

flush

public void flush()
           throws java.io.IOException
Description copied from interface: WebSocketContext
flushes the output stream

Specified by:
flush in interface WebSocketContext
Throws:
java.io.IOException

createWebSocketInputStream

protected WebSocketInputStream createWebSocketInputStream(FrameInputStream is)
                                                   throws java.io.IOException
Throws:
java.io.IOException

onClose

public void onClose(int closeCode,
                    java.lang.String closeMessage)
Specified by:
onClose in interface WebSocketContext

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

createOutputQueue

public <T> java.util.concurrent.BlockingQueue<T> createOutputQueue(WebSocketEncoder<T> encoder)
Description copied from interface: WebSocketContext
Creates a thread-safe queue, which applications can send objects to be marshaled.

Specified by:
createOutputQueue in interface WebSocketContext

setAutoFlush

public void setAutoFlush(boolean isAutoFlush)
Description copied from interface: WebSocketContext
auto-flush after each message is sent.

Specified by:
setAutoFlush in interface WebSocketContext

isAutoFlush

public boolean isAutoFlush()
Description copied from interface: WebSocketContext
returns the current flush mode.

Specified by:
isAutoFlush in interface WebSocketContext