Class WebSocketClient
java.lang.Object
com.cumulocity.sdk.client.notification2.internal.WebSocketClient
- All Implemented Interfaces:
WebSocketConnectorListener
This class is responsible for establishing and maintaining a websocket connection + connection token management.
It also notifies about received messages (notifications).
An instance of this class is created per subscription.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketClient(String webSocketBaseUrl, String subscriber, String subscriptionName, AckMode ackMode, String tenantId, String deviceId, NotificationListener notificationListener, boolean isTokenShared, boolean isTokenPersistent, Platform platform, WebSocketConnector connector) -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidonWebsocketClosed(int code, String reason) connection closedvoidconnection errorvoidonWebsocketMessage(String text) message receivedvoidconnection establishedvoidstart()Connects to web socketvoidstop(boolean unsubscribe) Disconnects and stops the client including scheduled jobs for reconnection
-
Field Details
-
MESSAGE_SHUTDOWN
- See Also:
-
-
Constructor Details
-
WebSocketClient
public WebSocketClient(String webSocketBaseUrl, String subscriber, String subscriptionName, AckMode ackMode, String tenantId, String deviceId, NotificationListener notificationListener, boolean isTokenShared, boolean isTokenPersistent, Platform platform, WebSocketConnector connector)
-
-
Method Details
-
start
public void start()Connects to web socket -
stop
public void stop(boolean unsubscribe) Disconnects and stops the client including scheduled jobs for reconnection -
onWebsocketClosed
Description copied from interface:WebSocketConnectorListenerconnection closed- Specified by:
onWebsocketClosedin interfaceWebSocketConnectorListener- Parameters:
code- closing codereason- closing reason
-
onWebsocketError
Description copied from interface:WebSocketConnectorListenerconnection error- Specified by:
onWebsocketErrorin interfaceWebSocketConnectorListener- Parameters:
t- exception details
-
onWebsocketOpen
public void onWebsocketOpen()Description copied from interface:WebSocketConnectorListenerconnection established- Specified by:
onWebsocketOpenin interfaceWebSocketConnectorListener
-
onWebsocketMessage
Description copied from interface:WebSocketConnectorListenermessage received- Specified by:
onWebsocketMessagein interfaceWebSocketConnectorListener- Parameters:
text- message text
-
getRawWebSocket
-
isRunning
public boolean isRunning()
-