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

@ -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)

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

View file

@ -28,7 +28,7 @@ object PushService {
}
fun Route.pushService() {
webSocket("/") {
webSocket("/websocket") {
PushService.clients += this
try {