Socket

class Socket(url: String, params: Payload?, gson: Gson, client: OkHttpClient)

Connects to a Phoenix Server

Constructors

Socket
Link copied to clipboard
fun Socket(url: String, params: Payload? = null, gson: Gson = Defaults.gson, client: OkHttpClient = OkHttpClient.Builder().build())

Functions

channel
Link copied to clipboard
fun channel(topic: String, params: Payload = mapOf()): Channel
connect
Link copied to clipboard
fun connect()
disconnect
Link copied to clipboard
fun disconnect(code: Int = WS_CLOSE_NORMAL, reason: String? = null, callback: () -> Unit? = null)
logItems
Link copied to clipboard
fun logItems(body: String)
off
Link copied to clipboard
fun off(refs: List<String>)
Removes onOpen, onClose, onError, and onMessage registrations by their ref value.
onClose
Link copied to clipboard
fun onClose(callback: () -> Unit): String
onError
Link copied to clipboard
fun onError(callback: (Throwable, Response?) -> Unit): String
onMessage
Link copied to clipboard
fun onMessage(callback: (Message) -> Unit): String
onOpen
Link copied to clipboard
fun onOpen(callback: () -> Unit): String
remove
Link copied to clipboard
fun remove(channel: Channel)
removeAllCallbacks
Link copied to clipboard
fun removeAllCallbacks()

Properties

endpoint
Link copied to clipboard
val endpoint: String
The string WebSocket endpoint (ie "ws://example.com/socket", "wss://example.com", etc.) that was passed to the Socket during initialization.
endpointUrl
Link copied to clipboard
val endpointUrl: URL
The fully qualified socket URL
heartbeatIntervalMs
Link copied to clipboard
var heartbeatIntervalMs: Long
Interval between sending a heartbeat, in ms
isConnected
Link copied to clipboard
val isConnected: Boolean
logger
Link copied to clipboard
var logger: (String) -> Unit? = null
The optional function to receive logs
params
Link copied to clipboard
val params: Payload?
The optional params to pass when connecting.
protocol
Link copied to clipboard
val protocol: String
reconnectAfterMs
Link copied to clipboard
var reconnectAfterMs: (Int) -> Long
Interval between socket reconnect attempts, in ms
rejoinAfterMs
Link copied to clipboard
var rejoinAfterMs: (Int) -> Long
Interval between channel rejoin attempts, in ms
skipHeartbeat
Link copied to clipboard
var skipHeartbeat: Boolean = false
Disables heartbeats from being sent.
timeout
Link copied to clipboard
var timeout: Long
Timeout to use when opening a connection