Package org.web3j.protocol.websocket
Class WebSocketClient
- java.lang.Object
-
- org.java_websocket.WebSocketAdapter
-
- org.java_websocket.AbstractWebSocket
-
- org.java_websocket.client.WebSocketClient
-
- org.web3j.protocol.websocket.WebSocketClient
-
- All Implemented Interfaces:
java.lang.Runnable
,org.java_websocket.WebSocket
,org.java_websocket.WebSocketListener
public class WebSocketClient extends org.java_websocket.client.WebSocketClient
Web socket client implementation that connects to a specify URI. Allows to provide a listener that will be called when a new message is received by the client.
-
-
Constructor Summary
Constructors Constructor Description WebSocketClient(java.net.URI serverUri)
WebSocketClient(java.net.URI serverUri, java.util.Map<java.lang.String,java.lang.String> httpHeaders)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onClose(int code, java.lang.String reason, boolean remote)
void
onError(java.lang.Exception e)
void
onMessage(java.lang.String s)
void
onOpen(org.java_websocket.handshake.ServerHandshake serverHandshake)
void
setListener(WebSocketListener listener)
Set a listener that will be called when a new message is received by the client.-
Methods inherited from class org.java_websocket.client.WebSocketClient
close, close, close, closeBlocking, closeConnection, connect, connectBlocking, getAttachment, getConnection, getConnections, getDraft, getLocalSocketAddress, getLocalSocketAddress, getReadyState, getRemoteSocketAddress, getRemoteSocketAddress, getResourceDescriptor, getSocket, getURI, hasBufferedData, isClosed, isClosing, isConnecting, isFlushAndClose, isOpen, onCloseInitiated, onClosing, onFragment, onMessage, onWebsocketClose, onWebsocketCloseInitiated, onWebsocketClosing, onWebsocketError, onWebsocketMessage, onWebsocketMessage, onWebsocketMessageFragment, onWebsocketOpen, onWriteDemand, reconnect, reconnectBlocking, run, send, send, send, sendFragmentedFrame, sendFrame, sendFrame, sendPing, setAttachment, setProxy, setSocket
-
Methods inherited from class org.java_websocket.AbstractWebSocket
getConnectionLostTimeout, isReuseAddr, isTcpNoDelay, setConnectionLostTimeout, setReuseAddr, setTcpNoDelay, startConnectionLostTimer, stopConnectionLostTimer
-
-
-
-
Method Detail
-
onOpen
public void onOpen(org.java_websocket.handshake.ServerHandshake serverHandshake)
- Specified by:
onOpen
in classorg.java_websocket.client.WebSocketClient
-
onMessage
public void onMessage(java.lang.String s)
- Specified by:
onMessage
in classorg.java_websocket.client.WebSocketClient
-
onClose
public void onClose(int code, java.lang.String reason, boolean remote)
- Specified by:
onClose
in classorg.java_websocket.client.WebSocketClient
-
onError
public void onError(java.lang.Exception e)
- Specified by:
onError
in classorg.java_websocket.client.WebSocketClient
-
setListener
public void setListener(WebSocketListener listener)
Set a listener that will be called when a new message is received by the client.- Parameters:
listener
- WebSocket listener
-
-