public class WebSocketClient extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
WebSocketClient.HttpResult |
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CONNECT_TIMEOUT |
static int |
DEFAULT_READ_TIMEOUT |
static Set<String> |
UPGRADE_HEADERS |
| Constructor and Description |
|---|
WebSocketClient(URL wsURL) |
| Modifier and Type | Method and Description |
|---|---|
protected Map<String,String> |
checkServerResponse(InputStream inputStream,
String nonce) |
CloseFrame |
close(int status,
String requestData,
int readTimeout)
Close the websocket connection properly, i.e.
|
WebSocketClient.HttpResult |
connect() |
WebSocketClient.HttpResult |
connect(int connectTimeout,
int readTimeout) |
WebSocketClient.HttpResult |
connect(Map<String,String> headers) |
WebSocketClient.HttpResult |
connect(Map<String,String> headers,
int connectTimeout,
int readTimeout) |
protected Socket |
createSocket(String host,
int port,
int connectTimeout,
int readTimeout) |
void |
dispose() |
void |
finalize() |
URL |
getConnectUrl() |
boolean |
isConnected() |
BinaryFrame |
receiveBinaryData(int timeout) |
CloseFrame |
receiveClose(int timeout) |
Frame |
receiveFrame(int readTimeout) |
PongFrame |
receivePong(int timeout) |
TextFrame |
receiveText(int timeout) |
BinaryFrame |
sendBinaryFrame(byte[] requestData) |
Frame |
sendClose(int closeStatus,
String reason) |
Frame |
sendPingFrame() |
Frame |
sendPingFrame(byte[] applicationData) |
Frame |
sendPongFrame() |
Frame |
sendPongFrame(byte[] applicationData) |
TextFrame |
sendTextFrame(String requestData) |
void |
setAdditionalUpgradeRequestHeaders(Map<String,String> additionalHeaders) |
void |
useProxy(String host,
int port,
String user,
String password) |
public static final int DEFAULT_CONNECT_TIMEOUT
public static final int DEFAULT_READ_TIMEOUT
public WebSocketClient(URL wsURL)
public URL getConnectUrl()
public void setAdditionalUpgradeRequestHeaders(Map<String,String> additionalHeaders)
public WebSocketClient.HttpResult connect() throws IOException, HttpException
IOExceptionHttpExceptionpublic WebSocketClient.HttpResult connect(int connectTimeout, int readTimeout) throws IOException, HttpException
IOExceptionHttpExceptionpublic WebSocketClient.HttpResult connect(Map<String,String> headers) throws IOException, HttpException
IOExceptionHttpExceptionpublic WebSocketClient.HttpResult connect(Map<String,String> headers, int connectTimeout, int readTimeout) throws IOException, HttpException
IOExceptionHttpExceptionpublic boolean isConnected()
protected Socket createSocket(String host, int port, int connectTimeout, int readTimeout) throws IOException
IOExceptionpublic void dispose()
public CloseFrame close(int status, String requestData, int readTimeout) throws IOException, UnexpectedFrameException
status - the status to send in the close framerequestData - the close reason to send as part of the close framereadTimeout - read timeout used when reading close responseIOException - when an IO exception occurs on the underlying connectionUnexpectedFrameException - when a frame is received that is not a close framepublic TextFrame sendTextFrame(String requestData) throws IOException
IOExceptionpublic BinaryFrame sendBinaryFrame(byte[] requestData) throws IOException
IOExceptionpublic Frame sendPingFrame() throws IOException
IOExceptionpublic Frame sendPingFrame(byte[] applicationData) throws IOException
IOExceptionpublic Frame sendPongFrame() throws IOException
IOExceptionpublic Frame sendPongFrame(byte[] applicationData) throws IOException
IOExceptionpublic Frame sendClose(int closeStatus, String reason) throws IOException
IOExceptionpublic CloseFrame receiveClose(int timeout) throws IOException, UnexpectedFrameException
IOExceptionUnexpectedFrameExceptionpublic Frame receiveFrame(int readTimeout) throws IOException
IOExceptionpublic TextFrame receiveText(int timeout) throws IOException, UnexpectedFrameException
IOExceptionUnexpectedFrameExceptionpublic BinaryFrame receiveBinaryData(int timeout) throws IOException, UnexpectedFrameException
IOExceptionUnexpectedFrameExceptionpublic PongFrame receivePong(int timeout) throws IOException, UnexpectedFrameException
IOExceptionUnexpectedFrameExceptionprotected Map<String,String> checkServerResponse(InputStream inputStream, String nonce) throws IOException
IOException