Add wss support

This commit is contained in:
Lars Westermann 2019-06-10 20:22:53 +02:00
parent 43e5bac871
commit 4f352de0d2
Signed by: lars.westermann
GPG key ID: 9D417FA5BB9D5E1D
3 changed files with 7 additions and 4 deletions

View file

@ -11,8 +11,11 @@ import org.w3c.dom.events.Event
import kotlin.browser.window
class WebSocketClient() {
val prefix = js("prefix")
private val url = "ws://${window.location.host}$prefix/"
private val prefix = js("prefix")
private val useSsl = "https" in window.location.protocol
private val wsProtocol = if (useSsl) "wss" else "ws"
private val url = "$wsProtocol://${window.location.host}$prefix/websocket"
private lateinit var ws: WebSocket
private var reconnect = false