All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jsMain.kotlinx.io.js.WebSockets.kt Maven / Gradle / Ivy

package kotlinx.io.js

import kotlinx.io.core.*
import org.khronos.webgl.*
import org.w3c.dom.*

fun WebSocket.sendPacket(packet: ByteReadPacket) {
    send(packet.readArrayBuffer())
}

inline fun WebSocket.sendPacket(block: BytePacketBuilder.() -> Unit) {
    sendPacket(buildPacket(block = block))
}

inline fun MessageEvent.packet(): ByteReadPacket {
    @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE", "UnsafeCastFromDynamic")
    return ByteReadPacket(IoBuffer(data.asDynamic(), null), IoBuffer.NoPool)
}








© 2015 - 2025 Weber Informatics LLC | Privacy Policy