Add wss support
This commit is contained in:
parent
43e5bac871
commit
4f352de0d2
3 changed files with 7 additions and 4 deletions
|
@ -31,7 +31,7 @@ fun formatTimeDiff(time: Long, now: Long): String {
|
||||||
hours > 1L -> {
|
hours > 1L -> {
|
||||||
val nowHour = DateFormat("HH")
|
val nowHour = DateFormat("HH")
|
||||||
.withLocale(KlockLocale.german)
|
.withLocale(KlockLocale.german)
|
||||||
.format(now).toInt() ?: 0
|
.format(now).toIntOrNull() ?: 0
|
||||||
|
|
||||||
val ht = DateFormat("HH:mm")
|
val ht = DateFormat("HH:mm")
|
||||||
.withLocale(KlockLocale.german)
|
.withLocale(KlockLocale.german)
|
||||||
|
|
|
@ -11,8 +11,11 @@ import org.w3c.dom.events.Event
|
||||||
import kotlin.browser.window
|
import kotlin.browser.window
|
||||||
|
|
||||||
class WebSocketClient() {
|
class WebSocketClient() {
|
||||||
val prefix = js("prefix")
|
private val prefix = js("prefix")
|
||||||
private val url = "ws://${window.location.host}$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 lateinit var ws: WebSocket
|
||||||
private var reconnect = false
|
private var reconnect = false
|
||||||
|
|
|
@ -28,7 +28,7 @@ object PushService {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Route.pushService() {
|
fun Route.pushService() {
|
||||||
webSocket("/") {
|
webSocket("/websocket") {
|
||||||
PushService.clients += this
|
PushService.clients += this
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue