mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
show call at start of invocation
This commit is contained in:
parent
8370ccdf13
commit
b246fc8f44
@ -404,7 +404,7 @@ export function useRingContext() {
|
||||
}
|
||||
|
||||
calling.current = { };
|
||||
updateState({ callStatus: "dialing" });
|
||||
updateState({ callStatus: "dialing", callId });
|
||||
|
||||
// create call
|
||||
const { server, token } = access.current;
|
||||
@ -451,7 +451,7 @@ export function useRingContext() {
|
||||
}
|
||||
}, RING);
|
||||
|
||||
updateState({ callStatus: "ringing", cardId });
|
||||
updateState({ callStatus: "ringing" });
|
||||
calling.current = { callId: id, host: true };
|
||||
const ice = [{ urls: iceUrl, username: iceUsername, credential: icePassword }];
|
||||
await connect('polite', server, callerToken, () => clearInterval(ringInterval), () => clearInterval(aliveInterval), ice);
|
||||
|
@ -136,8 +136,6 @@ export function useRingContext() {
|
||||
|
||||
const transmit = async (policy, ice) => {
|
||||
|
||||
console.log("TRANSMIT:", ice);
|
||||
|
||||
pc.current = new RTCPeerConnection({ iceServers: ice });
|
||||
pc.current.ontrack = (ev) => {
|
||||
if (!stream.current) {
|
||||
@ -186,8 +184,6 @@ console.log("TRANSMIT:", ice);
|
||||
|
||||
const connect = async (policy, node, token, clearRing, clearAlive, ice) => {
|
||||
|
||||
console.log("ICE CONNECT", ice);
|
||||
|
||||
// connect signal socket
|
||||
connected.current = false;
|
||||
candidates.current = [];
|
||||
@ -337,29 +333,30 @@ console.log("TRANSMIT:", ice);
|
||||
}
|
||||
},
|
||||
end: async () => {
|
||||
if (!calling.current) {
|
||||
throw new Error('inactive session');
|
||||
}
|
||||
try {
|
||||
const { host, callId, contactNode, contactToken } = calling.current;
|
||||
if (host) {
|
||||
await removeCall(access.current, callId);
|
||||
if (calling.current?.callId) {
|
||||
try {
|
||||
const { host, callId, contactNode, contactToken } = calling.current;
|
||||
if (host) {
|
||||
await removeCall(access.current, callId);
|
||||
}
|
||||
else {
|
||||
await removeContactCall(contactNode, contactToken, callId);
|
||||
}
|
||||
}
|
||||
else {
|
||||
await removeContactCall(contactNode, contactToken, callId);
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
if (ws.current) {
|
||||
ws.current.close();
|
||||
}
|
||||
if (videoTrack.current) {
|
||||
videoTrack.current.stop();
|
||||
videoTrack.current = null;
|
||||
}
|
||||
if (audioTrack.current) {
|
||||
audioTrack.current.stop();
|
||||
audioTrack.current = null;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
ws.current.close();
|
||||
if (videoTrack.current) {
|
||||
videoTrack.current.stop();
|
||||
videoTrack.current = null;
|
||||
}
|
||||
if (audioTrack.current) {
|
||||
audioTrack.current.stop();
|
||||
audioTrack.current = null;
|
||||
}
|
||||
},
|
||||
call: async (cardId, contactNode, contactToken) => {
|
||||
@ -367,8 +364,19 @@ console.log("TRANSMIT:", ice);
|
||||
throw new Error("active session");
|
||||
}
|
||||
|
||||
calling.current = {};
|
||||
updateState({ callStatus: "dialing", cardId });
|
||||
|
||||
// create call
|
||||
const call = await addCall(access.current, cardId);
|
||||
let call;
|
||||
try {
|
||||
call = await addCall(access.current, cardId);
|
||||
}
|
||||
catch (err) {
|
||||
calling.current = null;
|
||||
updateState({ callStatus: null });
|
||||
}
|
||||
|
||||
const { id, keepAlive, callerToken, calleeToken, iceUrl, iceUsername, icePassword } = call;
|
||||
try {
|
||||
await addContactRing(contactNode, contactToken, { index, callId: id, calleeToken, iceUrl, iceUsername, icePassword });
|
||||
@ -402,7 +410,7 @@ console.log("TRANSMIT:", ice);
|
||||
}
|
||||
}, RING);
|
||||
|
||||
updateState({ callStatus: "ringing", cardId });
|
||||
updateState({ callStatus: "ringing" });
|
||||
calling.current = { callId: id, host: true };
|
||||
const ice = [{ urls: iceUrl, username: iceUsername, credential: icePassword }];
|
||||
await connect('polite', window.location.host, callerToken, () => clearInterval(ringInterval), () => clearInterval(aliveInterval), ice);
|
||||
|
Loading…
Reference in New Issue
Block a user