-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
awb99
committed
Mar 11, 2024
1 parent
e716e82
commit 472d870
Showing
16 changed files
with
126 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(ns modular.ws.service | ||
(:require | ||
[taoensso.sente :as sente] | ||
[modular.ws.service.adapter :as adapter] | ||
[modular.ws.service.handler :as handler] | ||
[modular.ws.service.router :as router] | ||
[modular.ws.service.watch :as watch])) | ||
|
||
(defn start-websocket-server [server-type sente-debug?] | ||
(let [conn (adapter/ws-init! server-type) | ||
bidi-routes (handler/create-bidi-routes conn) | ||
router (router/start-router! conn) | ||
watch (watch/watch-conn-start conn)] | ||
(when sente-debug? | ||
(reset! sente/debug-mode?_ true)) | ||
{:conn conn | ||
:bidi-routes bidi-routes | ||
:router router | ||
:watch watch})) | ||
|
||
(defn stop-websocket-server [{:keys [conn bidi-routes router watch] :as state}] | ||
(router/stop-router! router)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/modular/ws/adapter/httpkit.clj → src/modular/ws/service/adapter/httpkit.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/modular/ws/adapter/jetty.clj → src/modular/ws/service/adapter/jetty.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/modular/ws/adapter/undertow.clj → src/modular/ws/service/adapter/undertow.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(ns modular.ws.id) | ||
(ns modular.ws.service.id) | ||
|
||
(defn unique-id | ||
"Get a unique id for a session." | ||
|
2 changes: 1 addition & 1 deletion
2
src/modular/ws/middleware.clj → src/modular/ws/service/middleware.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(ns modular.ws.service.router | ||
(:require | ||
[taoensso.sente :as sente] | ||
[modular.ws.msg-handler :refer [event-msg-handler]])) | ||
|
||
; router | ||
|
||
(defn stop-router! [stop-fn] | ||
(when stop-fn | ||
(stop-fn))) | ||
|
||
(defn start-router! [conn] | ||
(let [{:keys [ch-chsk]} conn] | ||
(sente/start-server-chsk-router! ch-chsk event-msg-handler))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(ns modular.ws.service.watch) | ||
|
||
|
||
(defn watch-conn-start [conn] | ||
(let [watcher-cbs (atom []) | ||
{:keys [connected-uids]} conn] | ||
(add-watch connected-uids :connected-uids | ||
(fn [_ _ old new] | ||
(when (not= old new) | ||
(doall (for [cb @watcher-cbs] | ||
(cb old new)))))) | ||
watcher-cbs | ||
)) | ||
|