hmt 3 anni fa
parent
commit
f8535264ff
3 ha cambiato i file con 10 aggiunte e 8 eliminazioni
  1. 1 1
      README.md
  2. 8 6
      app.ts
  3. 1 1
      mod.ts

+ 1 - 1
README.md

@@ -25,7 +25,7 @@ Then create a `servers.json` file like this here:
 
 Now you are ready to start the script with setting a port and a secret:
 
-    TINYSCALE_SECRET=some_secret_string deno run --allow-net --allow-read --allow-env https://deno.land/x/tinyscale@v1.6.0/mod.ts
+    TINYSCALE_SECRET=some_secret_string deno run --allow-net --allow-read --allow-env https://deno.land/x/tinyscale@v1.6.1/mod.ts
 
 tinyscale then runs on port 3005 and you will have to set up your reverse proxy so that it can pick up requests or you leave it on that port. If you prefer a different port you can set one with another env var: `PORT 3006`
 

+ 8 - 6
app.ts

@@ -6,7 +6,7 @@ const date = () => new Date().toLocaleTimeString('de')
 
 const S = new Servers()
 await S.init()
-let queue: Record<string, Deferred<boolean>> = {}
+let queue: Record<string, Deferred<string>> = {}
 
 const router = Router()
 // if the param is call, check for races
@@ -16,10 +16,12 @@ router.param('call', async (req, res, next, call) => {
   const existing_id = queue[meeting_id]
   if (existing_id) {
     console.log(`Race pending for meeting-ID: ${Color.red(meeting_id)}`)
-    await existing_id
+    const body = await existing_id
+    res.send(body)
+  } else {
+    queue[meeting_id] = deferred<string>();
+    next()
   }
-  queue[meeting_id] = deferred<boolean>();
-  next()
 })
 // the api itself answering to every call
 router.all("/:call", async (req, res, next) => {
@@ -46,11 +48,11 @@ router.all("/:call", async (req, res, next) => {
     try {
       const data = await fetch(redirect)
       const body = await data.text()
-      if (handler.call === 'create') { queue[handler.meeting_id].resolve(true); delete queue[handler.meeting_id] }
+      if (handler.call === 'create') { queue[handler.meeting_id].resolve(body); delete queue[handler.meeting_id] }
       res.set('Content-Type', 'text/xml');
       res.send(body)
     } catch (e) {
-      if (handler.call === 'create') { queue[handler.meeting_id].resolve(false); delete queue[handler.meeting_id] }
+      if (handler.call === 'create') { queue[handler.meeting_id].resolve(e); delete queue[handler.meeting_id] }
       next(createError(500))
     }
   }

+ 1 - 1
mod.ts

@@ -1,7 +1,7 @@
 import { Color, secret } from './deps.ts'
 
 const date = () => new Date().toLocaleTimeString('de')
-const VERSION = 'v1.6.0'
+const VERSION = 'v1.6.1'
 // give your tinyscale server a secret so it looks like a BBB server
 if (!secret) throw "No secret set for tinyscale"
 console.log(date() + Color.green(` Starting tinyscale ${VERSION}`))