public class WebSocketClient extends java.lang.Object implements WebSocketContext, 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 and Description |
|---|
WebSocketClient(java.lang.String url,
WebSocketListener listener) |
| Modifier and Type | Method and Description |
|---|---|
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) |
<T> java.util.concurrent.BlockingQueue<T> |
createOutputQueue(WebSocketEncoder<T> encoder)
Creates a thread-safe queue, which applications can send objects to be
marshaled.
|
void |
disconnect()
Disconnect the connection.
|
void |
flush()
flushes the output stream
|
java.io.InputStream |
getInputStream() |
long |
getTimeout()
Gets the read timeout.
|
boolean |
isAutoFlush()
returns the current flush mode.
|
boolean |
isClosed() |
void |
onClose(int closeCode,
java.lang.String closeMessage) |
protected void |
parseHeaders(ReadStream in) |
void |
pong(byte[] message)
sends a pong message
|
void |
setAutoFlush(boolean isAutoFlush)
auto-flush after each message is sent.
|
void |
setConnectTimeout(long timeout) |
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() |
public WebSocketClient(java.lang.String url,
WebSocketListener listener)
public void setVirtualHost(java.lang.String virtualHost)
public void setConnectTimeout(long timeout)
public void setMasked(boolean isMasked)
public void connect()
throws java.io.IOException
java.io.IOExceptionpublic void connect(java.lang.String userName,
java.lang.String password)
throws java.io.IOException
java.io.IOExceptionprotected void connectImpl(java.lang.String userName,
java.lang.String password)
throws java.io.IOException
java.io.IOExceptionprotected void parseHeaders(ReadStream in) throws java.io.IOException
java.io.IOExceptionpublic void disconnect()
WebSocketContextdisconnect in interface WebSocketContextpublic <T> java.util.concurrent.BlockingQueue<T> createOutputQueue(WebSocketEncoder<T> encoder)
WebSocketContextcreateOutputQueue in interface WebSocketContextpublic void setAutoFlush(boolean isAutoFlush)
WebSocketContextsetAutoFlush in interface WebSocketContextpublic boolean isAutoFlush()
WebSocketContextisAutoFlush in interface WebSocketContextpublic void flush()
throws java.io.IOException
WebSocketContextflush in interface WebSocketContextjava.io.IOExceptionpublic boolean isClosed()
public void close()
WebSocketContextclose in interface WebSocketContextpublic void close(int code,
java.lang.String msg)
WebSocketContextclose in interface WebSocketContextpublic java.io.InputStream getInputStream()
public java.io.OutputStream startBinaryMessage()
throws java.io.IOException
WebSocketContextstartBinaryMessage in interface WebSocketContextjava.io.IOExceptionpublic java.io.PrintWriter startTextMessage()
throws java.io.IOException
WebSocketContextstartTextMessage in interface WebSocketContextjava.io.IOExceptionpublic long getTimeout()
WebSocketContextgetTimeout in interface WebSocketContextpublic void setTimeout(long timeout)
WebSocketContextsetTimeout in interface WebSocketContextpublic void pong(byte[] message)
throws java.io.IOException
WebSocketContextpong in interface WebSocketContextjava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Objectpublic void onClose(int closeCode,
java.lang.String closeMessage)
onClose in interface WebSocketContext