com.caucho.remote.websocket
Class WebSocketClient

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

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

WebSocketClient


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
WebSocketClient(java.lang.String url, WebSocketListener listener)
           
 
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.
 void connect()
           
 void connect(java.lang.String userName, java.lang.String password)
           
protected  void connectImpl(java.lang.String userName, java.lang.String password)
           
 void disconnect()
          Disconnect the connection.
 java.io.InputStream getInputStream()
           
 long getTimeout()
          Gets the read timeout.
 boolean isClosed()
           
protected  void parseHeaders(ReadStream in)
           
 void pong(byte[] message)
          sends a pong message
 void setMasked(boolean isMasked)
           
 void setTimeout(long timeout)
          Sets the read timeout.
 void setVirtualHost(java.lang.String virtualHost)
           
 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

WebSocketClient

public WebSocketClient(java.lang.String url,
                       WebSocketListener listener)
Method Detail

setVirtualHost

public void setVirtualHost(java.lang.String virtualHost)

setMasked

public void setMasked(boolean isMasked)

connect

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

connect

public void connect(java.lang.String userName,
                    java.lang.String password)
             throws java.io.IOException
Throws:
java.io.IOException

connectImpl

protected void connectImpl(java.lang.String userName,
                           java.lang.String password)
                    throws java.io.IOException
Throws:
java.io.IOException

parseHeaders

protected void parseHeaders(ReadStream in)
                     throws java.io.IOException
Throws:
java.io.IOException

disconnect

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

Specified by:
disconnect in interface WebSocketContext

isClosed

public boolean isClosed()

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

getInputStream

public java.io.InputStream getInputStream()

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()
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

getTimeout

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

Specified by:
getTimeout in interface WebSocketContext

setTimeout

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

Specified by:
setTimeout in interface WebSocketContext

pong

public void pong(byte[] message)
          throws java.io.IOException
Description copied from interface: WebSocketContext
sends a pong message

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

toString

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