WebSocket

open external class WebSocket : EventTarget (source)

Platform and version requirements: JS

Exposes the JavaScript WebSocket to Kotlin

Constructors

<init>

WebSocket(
    url: String,
    protocols: dynamic = definedExternally)

Exposes the JavaScript WebSocket to Kotlin

Properties

binaryType

var binaryType: BinaryType

bufferedAmount

open val bufferedAmount: Int

extensions

open val extensions: String

onclose

var onclose: (Event) -> dynamic

onerror

var onerror: (Event) -> dynamic

onmessage

var onmessage: (Event) -> dynamic

onopen

var onopen: (Event) -> dynamic

protocol

open val protocol: String

readyState

open val readyState: Short

url

open val url: String

Functions

close

fun close(
    code: Short = definedExternally,
    reason: String = definedExternally)

send

fun send(data: String)
fun send(data: Blob)
fun send(data: ArrayBuffer)
fun send(data: ArrayBufferView)

Inherited Functions

addEventListener

fun addEventListener(
    type: String,
    callback: EventListener?,
    options: dynamic = definedExternally)
fun addEventListener(
    type: String,
    callback: (Event) -> Unit,
    options: dynamic = definedExternally)

dispatchEvent

fun dispatchEvent(event: Event): Boolean

removeEventListener

fun removeEventListener(
    type: String,
    callback: EventListener?,
    options: dynamic = definedExternally)
fun removeEventListener(
    type: String,
    callback: (Event) -> Unit,
    options: dynamic = definedExternally)

Companion Object Properties

CLOSED

val CLOSED: Short

CLOSING

val CLOSING: Short

CONNECTING

val CONNECTING: Short

OPEN

val OPEN: Short