Package io.github.ajacquierbret.kotlinphoenix.client

Types

Link copied to clipboard
class Channel(topic: String, params: Payload, socket: Socket, socketFlow: SocketFlow, scope: CoroutineScope) : SharedFlow<Message>

Represents a Channel bound to a given topic

Link copied to clipboard
typealias DecodeClosure = (String) -> Message

A closure that will decode a JSON String into a Message

Link copied to clipboard
object Defaults
Link copied to clipboard
actual object DefaultsPlatform
expect object DefaultsPlatform
actual object DefaultsPlatform
Link copied to clipboard
typealias EncodeClosure = (List<Any?>) -> String

A closure that will encode a Payload into a JSON String

Link copied to clipboard
data class Message(joinRef: String?, ref: String, topic: String, event: String, rawPayload: Payload)
Link copied to clipboard
typealias OnJoin = (key: String, current: PresenceMap?, new: PresenceMap) -> Unit

Closure signature of OnJoin callbacks

Link copied to clipboard
typealias OnLeave = (key: String, current: PresenceMap, left: PresenceMap) -> Unit

Closure signature for OnLeave callbacks

Link copied to clipboard
typealias OnSync = () -> Unit

Closure signature for OnSync callbacks

Link copied to clipboard
typealias Payload = Map<String, Any?>

Alias for a JSON mapping

Link copied to clipboard
typealias PayloadClosure = () -> Payload?

A closure that will return an optional Payload

Link copied to clipboard
class Presence(channel: Channel, scope: CoroutineScope, opts: Presence.Options)
Link copied to clipboard
typealias PresenceDiff = MutableMap<String, PresenceState>

Diff has keys "joins" and "leaves", pointing to a Presence.State each containing the users that joined and left.

Link copied to clipboard
typealias PresenceMap = MutableMap<String, List<PresenceMeta>>

A mapping of a String to an array of Metas. e.g. {"metas": {id: 1}}

Link copied to clipboard
typealias PresenceMeta = Map<String, Any>

Meta details of a Presence. Just a dictionary of properties

Link copied to clipboard
typealias PresenceState = MutableMap<String, PresenceMap>

A mapping of a Presence state to a mapping of Metas

Link copied to clipboard
class Push(channel: Channel, event: String, payload: Payload, timeout: Long, scope: CoroutineScope) : SharedFlow<Message>

A Push represents an attempt to send a payload through a Channel for a specific event.

Link copied to clipboard
actual class Socket(url: String, paramsClosure: PayloadClosure, vsn: String, encode: EncodeClosure, decode: DecodeClosure, scope: CoroutineScope) : SocketCommon
expect class Socket(url: String, paramsClosure: PayloadClosure, vsn: String, encode: EncodeClosure, decode: DecodeClosure, scope: CoroutineScope) : SocketCommon

A Socket which connects to a Phoenix Socket. Takes a closure to allow for changing parameters to be sent to the server when connecting.

actual class Socket(url: String, paramsClosure: PayloadClosure, vsn: String, encode: EncodeClosure, decode: DecodeClosure, scope: CoroutineScope) : SocketCommon
Link copied to clipboard
abstract class SocketCommon(params: PayloadClosure, vsn: String, encode: EncodeClosure, decode: DecodeClosure, scope: CoroutineScope)
Link copied to clipboard
sealed class SocketEvent : Throwable
Link copied to clipboard
typealias SocketFlow = SharedFlow<SocketEvent>

Alias for a SharedFlow of SocketEvent

Link copied to clipboard
class TimeoutTimer(timerCalculation: (tries: Int) -> Long, scope: CoroutineScope)

A Timer class that schedules a Job to be called in the future. Can be configured to use a custom retry pattern, such as exponential backoff.

Link copied to clipboard
interface Transport

Interface that defines different types of Transport layers.

Link copied to clipboard
actual typealias URL = URL
expect class URL
actual typealias URL = <ERROR CLASS>
Link copied to clipboard
actual class WebSocketTransport : WebSocketTransportCommon
expect class WebSocketTransport(url: URL, decode: DecodeClosure) : WebSocketTransportCommon

A WebSocket implementation of a Transport that uses a WebSocket to facilitate sending and receiving data.

actual class WebSocketTransport : WebSocketTransportCommon
Link copied to clipboard
abstract class WebSocketTransportCommon : Transport

Functions

Link copied to clipboard
fun List<*>.toJsonArray(): JsonArray
Link copied to clipboard
fun Any?.toJsonElement(): JsonElement
Link copied to clipboard
fun Map<*, *>.toJsonObject(): JsonObject
Link copied to clipboard
fun JsonElement.toPrimitive(): Any?
Link copied to clipboard
fun JsonObject.toPrimitiveMap(): Map<String, Any?>

Properties

Link copied to clipboard
const val WS_CLOSE_ABNORMAL: Int = 1006

RFC 6455: indicates that the connection was closed abnormally

Link copied to clipboard
const val WS_CLOSE_NORMAL: Int = 1000

RFC 6455: indicates a normal closure