WebSocket

open external class WebSocket(url: String, protocols: dynamic = definedExternally) : EventTarget(source)

Exposes the JavaScript WebSocket to Kotlin

Since Kotlin

1.1
open external class WebSocket(url: String, protocols: JsAny? = definedExternally) : EventTarget, JsAny(source)

Exposes the JavaScript WebSocket to Kotlin

Since Kotlin

1.8

Constructors

Link copied to clipboard
constructor(url: String, protocols: dynamic = definedExternally)
constructor(url: String, protocols: JsAny? = definedExternally)

Types

Link copied to clipboard
object Companion
Since Kotlin 1.1
object Companion
Since Kotlin 1.8

Properties

Link copied to clipboard
Since Kotlin 1.1
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.1
Since Kotlin 1.8
Link copied to clipboard
open val extensions: String
Since Kotlin 1.1
open val extensions: String
Since Kotlin 1.8
Link copied to clipboard
var onclose: (Event) -> dynamic?
Since Kotlin 1.1
var onclose: (Event) -> Unit?
Since Kotlin 1.8
Link copied to clipboard
var onerror: (Event) -> dynamic?
Since Kotlin 1.1
var onerror: (Event) -> Unit?
Since Kotlin 1.8
Link copied to clipboard
var onmessage: (MessageEvent) -> dynamic?
Since Kotlin 1.1
Since Kotlin 1.8
Link copied to clipboard
var onopen: (Event) -> dynamic?
Since Kotlin 1.1
var onopen: (Event) -> Unit?
Since Kotlin 1.8
Link copied to clipboard
open val protocol: String
Since Kotlin 1.1
open val protocol: String
Since Kotlin 1.8
Link copied to clipboard
open val readyState: Short
Since Kotlin 1.1
open val readyState: Short
Since Kotlin 1.8
Link copied to clipboard
open val url: String
Since Kotlin 1.1
open val url: String
Since Kotlin 1.8

Functions

Link copied to clipboard
fun addEventListener(type: String, callback: (Event) -> Unit?, options: dynamic = definedExternally)
fun addEventListener(type: String, callback: EventListener?, options: dynamic = definedExternally)
Since Kotlin 1.1
fun addEventListener(type: String, callback: (Event) -> Unit?)
fun addEventListener(type: String, callback: EventListener?)
fun addEventListener(type: String, callback: (Event) -> Unit?, options: Boolean)
fun addEventListener(type: String, callback: (Event) -> Unit?, options: AddEventListenerOptions)
fun addEventListener(type: String, callback: EventListener?, options: Boolean)
Since Kotlin 1.8
Link copied to clipboard
fun close(code: Short = definedExternally, reason: String = definedExternally)
Since Kotlin 1.1
fun close(code: Short = definedExternally, reason: String = definedExternally)
Since Kotlin 1.8
Link copied to clipboard
Since Kotlin 1.1
Since Kotlin 1.8
Link copied to clipboard
fun removeEventListener(type: String, callback: (Event) -> Unit?, options: dynamic = definedExternally)
fun removeEventListener(type: String, callback: EventListener?, options: dynamic = definedExternally)
Since Kotlin 1.1
fun removeEventListener(type: String, callback: (Event) -> Unit?)
fun removeEventListener(type: String, callback: (Event) -> Unit?, options: Boolean)
fun removeEventListener(type: String, callback: (Event) -> Unit?, options: EventListenerOptions)
fun removeEventListener(type: String, callback: EventListener?, options: Boolean)
Since Kotlin 1.8
Link copied to clipboard
fun send(data: String)
fun send(data: ArrayBuffer)
fun send(data: Blob)
Since Kotlin 1.1
fun send(data: String)
fun send(data: ArrayBuffer)
fun send(data: Blob)
Since Kotlin 1.8
Link copied to clipboard

For a Dynamic value caught in JS, returns the corresponding Throwable if it was thrown from Kotlin, or null otherwise.

Since Kotlin 1.8
Link copied to clipboard
fun <T : JsAny> JsAny.unsafeCast(): T

Cast JsAny to other Js type without runtime check

Since Kotlin 1.8