enhance(rtc): validate graph skeleton data when start-rtc

This commit is contained in:
rcmerci
2024-06-16 19:41:39 +08:00
parent e6809fb497
commit 9ab79bfe38
7 changed files with 142 additions and 67 deletions

View File

@@ -0,0 +1,20 @@
(ns frontend.worker.rtc.ws-util
"Add RTC related logic to the function based on ws."
(:require [missionary.core :as m]
[frontend.worker.rtc.exception :as r.ex]
[frontend.worker.rtc.ws :as ws]))
(defn- handle-remote-ex
[resp]
(if-let [e ({:graph-not-exist r.ex/ex-remote-graph-not-exist
:graph-not-ready r.ex/ex-remote-graph-not-ready}
(:type (:ex-data resp)))]
(throw e)
resp))
(defn send&recv
"Return a task: throw exception if recv ex-data response"
[get-ws-create-task message]
(m/sp
(let [ws (m/? get-ws-create-task)]
(handle-remote-ex (m/? (ws/send&recv ws message))))))