diff --git a/src/commonMain/kotlin/de/kif/common/DateFormat.kt b/src/commonMain/kotlin/de/kif/common/DateFormat.kt index 50cedd6..c210e99 100644 --- a/src/commonMain/kotlin/de/kif/common/DateFormat.kt +++ b/src/commonMain/kotlin/de/kif/common/DateFormat.kt @@ -31,7 +31,7 @@ fun formatTimeDiff(time: Long, now: Long): String { hours > 1L -> { val nowHour = DateFormat("HH") .withLocale(KlockLocale.german) - .format(now).toInt() ?: 0 + .format(now).toIntOrNull() ?: 0 val ht = DateFormat("HH:mm") .withLocale(KlockLocale.german) diff --git a/src/jsMain/kotlin/de/kif/frontend/WebSocketClient.kt b/src/jsMain/kotlin/de/kif/frontend/WebSocketClient.kt index 34916fa..62464af 100644 --- a/src/jsMain/kotlin/de/kif/frontend/WebSocketClient.kt +++ b/src/jsMain/kotlin/de/kif/frontend/WebSocketClient.kt @@ -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 diff --git a/src/jvmMain/kotlin/de/kif/backend/util/PushService.kt b/src/jvmMain/kotlin/de/kif/backend/util/PushService.kt index d76ac93..12f07e3 100644 --- a/src/jvmMain/kotlin/de/kif/backend/util/PushService.kt +++ b/src/jvmMain/kotlin/de/kif/backend/util/PushService.kt @@ -28,7 +28,7 @@ object PushService { } fun Route.pushService() { - webSocket("/") { + webSocket("/websocket") { PushService.clients += this try {