MCPcopy Create free account
hub / github.com/ACM-VIT/conclave / getToken

Function getToken

scripts/loadtest/loadtest.mjs:92–122  ·  view source on GitHub ↗
({ name, sessionId, isHost })

Source from the content-addressed store, hash-verified

90const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
91
92async function getToken({ name, sessionId, isHost }) {
93 const resp = await fetch(NEXT_API, {
94 method: "POST",
95 headers: {
96 "content-type": "application/json",
97 "x-sfu-client": CLIENT_ID,
98 },
99 body: JSON.stringify({
100 roomId: ROOM_ID,
101 sessionId,
102 user: { name },
103 clientId: CLIENT_ID,
104 isHost: Boolean(isHost),
105 allowRoomCreation: Boolean(isHost),
106 }),
107 });
108 if (!resp.ok) {
109 const text = await resp.text().catch(() => "");
110 throw new Error(`token ${resp.status}: ${text.slice(0, 120)}`);
111 }
112 const payload = await resp.json().catch(() => null);
113 if (
114 !payload ||
115 typeof payload !== "object" ||
116 typeof payload.token !== "string" ||
117 typeof payload.sfuUrl !== "string"
118 ) {
119 throw new Error("token response missing token or sfuUrl");
120 }
121 return payload;
122}
123
124const state = {
125 attempted: 0,

Callers 1

spawnParticipantFunction · 0.85

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected