mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
🎉 Add ping message on websocket communication.
Every 30seconds (for reset the default nginx proxy timeout).
This commit is contained in:
parent
e805515767
commit
044f8487e2
3 changed files with 22 additions and 15 deletions
|
@ -20,11 +20,12 @@
|
|||
[uxbox.util.uuid :as uuid]
|
||||
[vertx.eventbus :as ve]
|
||||
[vertx.http :as vh]
|
||||
[vertx.impl :as vi]
|
||||
[vertx.util :as vu]
|
||||
[vertx.timers :as vt]
|
||||
[vertx.web :as vw]
|
||||
[vertx.web.websockets :as ws])
|
||||
(:import
|
||||
java.lang.AutoCloseable
|
||||
io.vertx.core.Handler
|
||||
io.vertx.core.Promise
|
||||
io.vertx.core.Vertx
|
||||
|
@ -91,9 +92,11 @@
|
|||
ws (assoc ws
|
||||
:user-id user-id
|
||||
:file-id file-id)
|
||||
sem (start-eventbus-consumer! ctx ws file-id)]
|
||||
send-ping #(send! ws {:type :ping})
|
||||
sem1 (start-eventbus-consumer! ctx ws file-id)
|
||||
sem2 (vt/schedule-periodic! ctx 30000 send-ping)]
|
||||
(handle-message ws {:type :connect})
|
||||
(assoc ws ::sem sem)))
|
||||
(assoc ws ::sem1 sem1 ::sem2 sem2)))
|
||||
|
||||
(defn- on-text-message
|
||||
[ws message]
|
||||
|
@ -106,7 +109,8 @@
|
|||
(let [file-id (:file-id ws)]
|
||||
(handle-message ws {:type :disconnect
|
||||
:file-id file-id})
|
||||
(.unregister (::sem ws))))
|
||||
(.close ^AutoCloseable (::sem1 ws))
|
||||
(.close ^AutoCloseable (::sem2 ws))))
|
||||
|
||||
(defn handler
|
||||
[{:keys [user] :as req}]
|
||||
|
|
7
backend/vendor/vertx/src/vertx/eventbus.clj
vendored
7
backend/vendor/vertx/src/vertx/eventbus.clj
vendored
|
@ -7,7 +7,8 @@
|
|||
(ns vertx.eventbus
|
||||
(:require [promesa.core :as p]
|
||||
[vertx.impl :as impl])
|
||||
(:import io.vertx.core.Vertx
|
||||
(:import
|
||||
io.vertx.core.Vertx
|
||||
io.vertx.core.Handler
|
||||
io.vertx.core.Context
|
||||
io.vertx.core.eventbus.Message
|
||||
|
@ -36,7 +37,9 @@
|
|||
(.resume consumer)
|
||||
(.reply msg (or res err)
|
||||
(opts->delivery-opts {}))))))))
|
||||
consumer))
|
||||
(reify java.lang.AutoCloseable
|
||||
(close [it]
|
||||
(.unregister consumer)))))
|
||||
|
||||
(defn publish!
|
||||
([vsm topic msg] (publish! vsm topic msg {}))
|
||||
|
|
2
backend/vendor/vertx/src/vertx/timers.clj
vendored
2
backend/vendor/vertx/src/vertx/timers.clj
vendored
|
@ -26,7 +26,7 @@
|
|||
(close [_]
|
||||
(.cancelTimer system timer-id)))))
|
||||
|
||||
(defn sechdule-periodic!
|
||||
(defn schedule-periodic!
|
||||
[vsm ms f]
|
||||
(let [^Vertx system (impl/resolve-system vsm)
|
||||
^Handler handler (impl/fn->handler (fn [v] (f)))
|
||||
|
|
Loading…
Add table
Reference in a new issue