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.IOException
public void connect(java.lang.String userName, java.lang.String password) throws java.io.IOException
java.io.IOException
protected void connectImpl(java.lang.String userName, java.lang.String password) throws java.io.IOException
java.io.IOException
protected void parseHeaders(ReadStream in) throws java.io.IOException
java.io.IOException
public void disconnect()
WebSocketContext
disconnect
in interface WebSocketContext
public <T> java.util.concurrent.BlockingQueue<T> createOutputQueue(WebSocketEncoder<T> encoder)
WebSocketContext
createOutputQueue
in interface WebSocketContext
public void setAutoFlush(boolean isAutoFlush)
WebSocketContext
setAutoFlush
in interface WebSocketContext
public boolean isAutoFlush()
WebSocketContext
isAutoFlush
in interface WebSocketContext
public void flush() throws java.io.IOException
WebSocketContext
flush
in interface WebSocketContext
java.io.IOException
public boolean isClosed()
public void close()
WebSocketContext
close
in interface WebSocketContext
public void close(int code, java.lang.String msg)
WebSocketContext
close
in interface WebSocketContext
public java.io.InputStream getInputStream()
public java.io.OutputStream startBinaryMessage() throws java.io.IOException
WebSocketContext
startBinaryMessage
in interface WebSocketContext
java.io.IOException
public java.io.PrintWriter startTextMessage() throws java.io.IOException
WebSocketContext
startTextMessage
in interface WebSocketContext
java.io.IOException
public long getTimeout()
WebSocketContext
getTimeout
in interface WebSocketContext
public void setTimeout(long timeout)
WebSocketContext
setTimeout
in interface WebSocketContext
public void pong(byte[] message) throws java.io.IOException
WebSocketContext
pong
in interface WebSocketContext
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public void onClose(int closeCode, java.lang.String closeMessage)
onClose
in interface WebSocketContext