Socket
class Socket(url: String, paramsClosure: PayloadClosure, vsn: String, encode: EncodeClosure, decode: DecodeClosure, client: OkHttpClient)
Content copied to clipboard
A Socket which connects to a Phoenix Server. Takes a closure to allow for changing parameters to be sent to the server when connecting.
Example
val socket = Socket("https://example.com/socket", { mapOf("token" to mAuthToken) })Parameters
url
Url to connect to such as https://example.com/socket
paramsClosure
Closure which allows to change parameters sent during connection.
vsn
JSON Serializer version to use. Defaults to 2.0.0
encode
Optional. Provide a custom JSON encoding implementation
decode
Optional. Provide a custom JSON decoding implementation
client
Default OkHttpClient to connect with. You can provide your own if needed.
Constructors
Socket
Link copied to clipboard
fun Socket(url: String, params: Payload = mapOf(), vsn: String = Defaults.VSN, encode: EncodeClosure = Defaults.encode, decode: DecodeClosure = Defaults.decode, client: OkHttpClient = OkHttpClient.Builder().build())
Content copied to clipboard
A Socket which connects to a Phoenix Server.
Socket
Link copied to clipboard
fun Socket(url: String, paramsClosure: PayloadClosure, vsn: String = Defaults.VSN, encode: EncodeClosure = Defaults.encode, decode: DecodeClosure = Defaults.decode, client: OkHttpClient = OkHttpClient.Builder().build())
Content copied to clipboard
Url to connect to such as https://example.
Functions
disconnect
Link copied to clipboard
fun disconnect(code: Int = WS_CLOSE_NORMAL, reason: String? = null, callback: () -> Unit? = null)
Content copied to clipboard
removeAllCallbacks
Link copied to clipboard
fun removeAllCallbacks()
Content copied to clipboard
Properties
connectionState
Link copied to clipboard
endpointUrl
Link copied to clipboard
heartbeatIntervalMs
Link copied to clipboard
isConnected
Link copied to clipboard
paramsClosure
Link copied to clipboard
reconnectAfterMs
Link copied to clipboard
rejoinAfterMs
Link copied to clipboard
skipHeartbeat
Link copied to clipboard