displaying call at invocation

This commit is contained in:
Roland Osborne 2023-04-14 09:45:07 -07:00
parent 1544512e4a
commit 8370ccdf13

View File

@ -379,32 +379,45 @@ export function useRingContext() {
}
},
end: async () => {
if (!calling.current) {
throw new Error('inactive session');
}
try {
const { host, callId, contactNode, contactToken } = calling.current;
if (host) {
const { server, token } = access.current;
await removeCall(server, token, callId);
if (calling.current?.callId) {
try {
const { host, callId, contactNode, contactToken } = calling.current;
if (host) {
const { server, token } = access.current;
await removeCall(server, token, callId);
}
else {
await removeContactCall(contactNode, contactToken, callId);
}
}
else {
await removeContactCall(contactNode, contactToken, callId);
catch (err) {
console.log(err);
}
if (ws.current) {
ws.current.close();
}
}
catch (err) {
console.log(err);
}
ws.current.close();
},
call: async (cardId, contactNode, contactToken) => {
if (calling.current) {
throw new Error("active session");
}
calling.current = { };
updateState({ callStatus: "dialing" });
// create call
const { server, token } = access.current;
const call = await addCall(server, token, cardId);
let call;
try {
call = await addCall(server, token, cardId);
}
catch (err) {
calling.current = null;
updateState({ callStatus: null });
throw err;
}
const { id, keepAlive, callerToken, calleeToken, iceUrl, iceUsername, icePassword } = call;
try {
await addContactRing(contactNode, contactToken, { index, callId: id, calleeToken, iceUrl, iceUsername, icePassword });