SocketManagerImpl

Android implementation of SocketManager

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val id: String?

Unique identifier of the underlying socket connection, when available.

Functions

Link copied to clipboard
open suspend override fun connect(url: String, config: SocketConfig): Result<Unit>

Connect to a Socket.IO server.

Link copied to clipboard
open suspend override fun disconnect(): Result<Unit>

Disconnect from the Socket.IO server. Cleans up all event handlers and closes the connection.

Link copied to clipboard
open suspend override fun emit(event: String, data: Map<String, Any?>)

Emit an event to the server without waiting for acknowledgment.

Link copied to clipboard
open override fun emitWithAck(event: String, data: Map<String, Any?>, callback: (Any?) -> Unit)

Emit an event and invoke callback when the acknowledgment arrives.

open suspend override fun <T> emitWithAck(event: String, data: Map<String, Any?>, timeout: Long): T

Emit an event and wait for acknowledgment from the server.

Link copied to clipboard
open override fun getConnectionState(): ConnectionState

Get the current connection state.

Link copied to clipboard
open override fun isConnected(): Boolean

Check if currently connected to the server.

Link copied to clipboard
open override fun off(event: String)

Unregister a handler for a specific event.

Link copied to clipboard
open override fun offAll()

Remove all event handlers.

Link copied to clipboard
open override fun on(event: String, handler: suspend (Map<String, Any?>) -> Unit)

Register a handler for a specific event. The handler will be called whenever the event is received from the server.

Link copied to clipboard
open override fun onConnect(handler: suspend () -> Unit)

Register a handler for connection events. Called when the socket successfully connects.

Link copied to clipboard
open override fun onDisconnect(handler: suspend (String) -> Unit)

Register a handler for disconnection events. Called when the socket disconnects (either intentionally or due to error).

Link copied to clipboard
open override fun onError(handler: suspend (Throwable) -> Unit)

Register a handler for error events. Called when a connection or communication error occurs.

Link copied to clipboard
open override fun onReconnect(handler: suspend (Int) -> Unit)

Register a handler for reconnection events. Called when the socket successfully reconnects after a disconnection.

Link copied to clipboard
open override fun onReconnectAttempt(handler: suspend (Int) -> Unit)

Register a handler for reconnection attempts. Called before each reconnection attempt.

Link copied to clipboard
open override fun onReconnectFailed(handler: suspend () -> Unit)

Register a handler for reconnection failures. Called when all reconnection attempts have been exhausted.