public interface WebSocketClient
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(WebSocketClientListener aListener)
Adds the client listener to the lists of listener which are interested in
receiving the jWebSocket connection and data events.
|
void |
addSubProtocol(WebSocketSubProtocol aSubProt)
Adds subprotocol to the list of supported protocols which are negotiated
during handshake with web socket server.
|
void |
close()
Close the jWebSocket connection.
|
List<WebSocketClientListener> |
getListeners()
Returns the list of listeners registered.
|
WebSocketEncoding |
getNegotiatedEncoding()
If subprotocol was negotiated, then this method returns sub protocol
format (json, csv, binary, custom)
|
String |
getNegotiatedSubProtocol()
If subprotocol was negotiated, then this method returns sub protocol
name.
|
WebSocketStatus |
getStatus()
Method to return if the status of the jWebSocketClient
|
boolean |
isConnected()
Method to check if the jWebSocketClient is still connected to the
jWebSocketServer
|
void |
notifyClosed(WebSocketClientEvent aEvent)
Notifies the jWebSocket client implementation about the
connection being closed
|
void |
notifyOpened(WebSocketClientEvent aEvent)
Notifies the jWebSocket client implementation about the
connection being opened to the jWebSocket server via WebSocket
|
void |
notifyPacket(WebSocketClientEvent aEvent,
WebSocketPacket aPacket)
Notifies the jWebSocket client implementation about the packet
being received from the WebSocket client.
|
void |
notifyReconnecting(WebSocketClientEvent aEvent)
Notifies the jWebSocket client implementation about the
connection being re-established
|
void |
open(String aURL)
Opens the jWebSocket connection
|
void |
removeListener(WebSocketClientListener aListener)
Remove the listener from the list of listeners, once the listener is
removed it won't be notified of any jWebSocket events.
|
void |
send(byte[] aData)
Send the given byte data to the server
|
void |
send(String aData,
String aEncoding)
Sends the data to the jWebSocket server, data has to be UTF-8 encoded.
|
void |
send(WebSocketPacket aPacket)
Sends the websocket data packet to the WebSocket client
|
void |
setVersion(int aVersion)
Web socket protocol draft.
|
void open(String aURL) throws WebSocketException
aURL - the websocket connection urlWebSocketException - if therre's anvoid send(byte[] aData)
throws WebSocketException
aData - the byte dataWebSocketException - if exception occurs while sending the datavoid send(String aData, String aEncoding) throws WebSocketException
aData - the data to sendaEncoding - the encoding typeWebSocketException - if there's any exception while sending the
datavoid send(WebSocketPacket aPacket) throws WebSocketException
aPacket - the data packet to sendWebSocketException - if there's any exception while sendingvoid close()
throws WebSocketException
WebSocketException - if exception while close operationboolean isConnected()
true if there's a persistent connection false
otherwiseWebSocketStatus getStatus()
void notifyOpened(WebSocketClientEvent aEvent)
aEvent - the websocket client event objectvoid notifyPacket(WebSocketClientEvent aEvent, WebSocketPacket aPacket)
aEvent - the websocket client event objectaPacket - the data packet receivedvoid notifyClosed(WebSocketClientEvent aEvent)
aEvent - the websocket client event objectvoid notifyReconnecting(WebSocketClientEvent aEvent)
aEvent - the websocket client event objectvoid addListener(WebSocketClientListener aListener)
aListener - the event listener objectvoid removeListener(WebSocketClientListener aListener)
aListener - the listener object to removeList<WebSocketClientListener> getListeners()
void addSubProtocol(WebSocketSubProtocol aSubProt)
aSubProt - sub protocolaEncoding, - currently either text or binaryString getNegotiatedSubProtocol()
WebSocketEncoding getNegotiatedEncoding()
void setVersion(int aVersion)
aVersion - which draft to use for web socket protocol communicationCopyright © 2013. All Rights Reserved.