Class SocketListener
-
- All Implemented Interfaces:
public class SocketListenerListener which is invoked for WebSocket events.
-
-
Field Summary
Fields Modifier and Type Field Description private final BooleandeliverOnMainThread
-
Constructor Summary
Constructors Constructor Description SocketListener()
-
Method Summary
Modifier and Type Method Description BooleangetDeliverOnMainThread()The callbacks are by default delivered on the main thread. UnitonConnecting()Invoked when the connection begins to establish and socket state changes to Connecting. UnitonConnected(ConnectedEvent event)Invoked when we receive the first ConnectedEvent in this connection. UnitonDisconnected(DisconnectCause cause)Invoked when the web socket connection is disconnected. UnitonError(Error error)Invoked when there is any error in this web socket connection. UnitonEvent(ChatEvent event)Invoked when we receive any successful event. -
-
Method Detail
-
getDeliverOnMainThread
Boolean getDeliverOnMainThread()
The callbacks are by default delivered on the main thread. Changing this property to false will deliver the callbacks on their originating threads.
Set to false for faster callback delivery on the original thread (no unnecessary context switching).
-
onConnecting
Unit onConnecting()
Invoked when the connection begins to establish and socket state changes to Connecting.
-
onConnected
Unit onConnected(ConnectedEvent event)
Invoked when we receive the first ConnectedEvent in this connection.
Note: This is not invoked when the ws connection is opened but when the ConnectedEvent is received.
- Parameters:
event- ConnectedEvent sent by server as first event once the connection is established.
-
onDisconnected
Unit onDisconnected(DisconnectCause cause)
Invoked when the web socket connection is disconnected.
- Parameters:
cause- DisconnectCause reason of disconnection.
-
onError
Unit onError(Error error)
Invoked when there is any error in this web socket connection.
- Parameters:
error- Error object with the error details.
-
-
-
-