SocketApi

interface SocketApi

The SocketApi maintains a WebSocket connection to the current server specified in its parent ApiClient. Each ApiClient has one SocketApi instance. Updating the server URL, device info, client info or access token using the update function will automatically propagate and reconnect the WebSocket.

The WebSocket automatically disconnects when there are no active subscriptions. Subscriptions will automatically send the appropriate start and stop messages to the server, the start messages will always request an interval of one second. Prefer using individual subscriptions above the subscribeAll function for best performance.

Inheritors

Properties

Link copied to clipboard
abstract val state: <Error class: unknown class><SocketApiState>

Flow indicating the current status of the WebSocket connection.

Functions

Link copied to clipboard
abstract fun <T> subscribe(messageType: KClass<T>): <Error class: unknown class><T>

Subscribe to a specific WebSocket message type.

Link copied to clipboard
inline fun <T> SocketApi.subscribe(): <Error class: unknown class><T>

Subscribe to a specific WebSocket message type.

Link copied to clipboard
abstract fun subscribeAll(): <Error class: unknown class><<Error class: unknown class>>

Subscribe to all incoming WebSocket messages.

Link copied to clipboard
inline fun SocketApi.subscribeGeneralCommand(command: <Error class: unknown class>): <Error class: unknown class><<Error class: unknown class>>

Subscribe to a specific GeneralCommandType message.

Link copied to clipboard
inline fun SocketApi.subscribeGeneralCommands(commands: Set<<Error class: unknown class>> = GeneralCommandType.values().toSet()): <Error class: unknown class><<Error class: unknown class>>

Subscribe to specific GeneralCommandType messages.

Link copied to clipboard
inline fun SocketApi.subscribePlayStateCommand(command: <Error class: unknown class>): <Error class: unknown class><<Error class: unknown class>>

Subscribe to a specific PlaystateCommand message.

Link copied to clipboard
inline fun SocketApi.subscribePlayStateCommands(commands: Set<<Error class: unknown class>> = PlaystateCommand.values().toSet()): <Error class: unknown class><<Error class: unknown class>>

Subscribe to specific PlaystateCommand messages.

Link copied to clipboard
inline fun SocketApi.subscribeSyncPlayCommand(command: <Error class: unknown class>): <Error class: unknown class><<Error class: unknown class>>

Subscribe to a specific SendCommandType message.

Link copied to clipboard
inline fun SocketApi.subscribeSyncPlayCommands(commands: Set<<Error class: unknown class>> = SendCommandType.values().toSet()): <Error class: unknown class><<Error class: unknown class>>

Subscribe to specific SendCommandType messages.