mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
fixing call exit handling
This commit is contained in:
parent
8376f75f9c
commit
09e0ffbe34
@ -56,7 +56,7 @@ func AddCall(w http.ResponseWriter, r *http.Request) {
|
|||||||
// allocate bridge
|
// allocate bridge
|
||||||
callerToken := hex.EncodeToString(callerBin);
|
callerToken := hex.EncodeToString(callerBin);
|
||||||
calleeToken := hex.EncodeToString(calleeBin);
|
calleeToken := hex.EncodeToString(calleeBin);
|
||||||
bridgeRelay.AddBridge(account.ID, callId, callerToken, calleeToken);
|
bridgeRelay.AddBridge(account.ID, callId, cardId, callerToken, calleeToken);
|
||||||
|
|
||||||
// create response
|
// create response
|
||||||
call := Call{
|
call := Call{
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
package databag
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
//EndCall termines an active call
|
|
||||||
func EndCall(w http.ResponseWriter, r *http.Request) {
|
|
||||||
}
|
|
@ -31,12 +31,13 @@ type BridgeRelay struct {
|
|||||||
bridges []*Bridge
|
bridges []*Bridge
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *BridgeRelay) AddBridge(accountId uint, callId string, callerToken string, calleeToken string) {
|
func (s *BridgeRelay) AddBridge(accountId uint, callId string, cardId string, callerToken string, calleeToken string) {
|
||||||
s.sync.Lock()
|
s.sync.Lock()
|
||||||
defer s.sync.Unlock()
|
defer s.sync.Unlock()
|
||||||
bridge := &Bridge{
|
bridge := &Bridge{
|
||||||
accountId: accountId,
|
accountId: accountId,
|
||||||
callId: callId,
|
callId: callId,
|
||||||
|
cardId: cardId,
|
||||||
expires: time.Now().Unix() + (BridgeKeepAlive * 3),
|
expires: time.Now().Unix() + (BridgeKeepAlive * 3),
|
||||||
closed: false,
|
closed: false,
|
||||||
callerToken: callerToken,
|
callerToken: callerToken,
|
||||||
|
@ -815,7 +815,7 @@ var endpoints = routes{
|
|||||||
"EndCall",
|
"EndCall",
|
||||||
strings.ToUpper("Delete"),
|
strings.ToUpper("Delete"),
|
||||||
"/talk/calls/{callId}",
|
"/talk/calls/{callId}",
|
||||||
EndCall,
|
RemoveCall,
|
||||||
},
|
},
|
||||||
|
|
||||||
route{
|
route{
|
||||||
|
@ -64,13 +64,19 @@ export function useRingContext() {
|
|||||||
updateState({ ringing: ringing.current });
|
updateState({ ringing: ringing.current });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
decline: (cardId, callId) => {
|
decline: async (cardId, contactNode, contactToken, callId) => {
|
||||||
const key = `${cardId}:${callId}`
|
const key = `${cardId}:${callId}`
|
||||||
const call = ringing.current.get(key);
|
const call = ringing.current.get(key);
|
||||||
if (call) {
|
if (call) {
|
||||||
call.status = 'declined'
|
call.status = 'declined'
|
||||||
ringing.current.set(key, call);
|
ringing.current.set(key, call);
|
||||||
updateState({ ringing: ringing.current });
|
updateState({ ringing: ringing.current });
|
||||||
|
try {
|
||||||
|
await removeContactCall(contactNode, contactToken, callId);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
accept: async (cardId, callId, contactNode, contactToken, calleeToken) => {
|
accept: async (cardId, callId, contactNode, contactToken, calleeToken) => {
|
||||||
@ -121,7 +127,10 @@ export function useRingContext() {
|
|||||||
// handle messages [impolite]
|
// handle messages [impolite]
|
||||||
try {
|
try {
|
||||||
const signal = JSON.parse(ev.data);
|
const signal = JSON.parse(ev.data);
|
||||||
if (signal.description) {
|
if (signal.status === 'closed') {
|
||||||
|
ws.current.close();
|
||||||
|
}
|
||||||
|
else if (signal.description) {
|
||||||
stream.current = null;
|
stream.current = null;
|
||||||
if (signal.description.type === 'offer' && pc.current.signalingState !== 'stable') {
|
if (signal.description.type === 'offer' && pc.current.signalingState !== 'stable') {
|
||||||
return; //rudely ignore
|
return; //rudely ignore
|
||||||
@ -262,12 +271,14 @@ export function useRingContext() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
videoTrack.current = false;
|
||||||
|
audioTrack.current = false;
|
||||||
accessVideo.current = false;
|
accessVideo.current = false;
|
||||||
const stream = await navigator.mediaDevices.getUserMedia({
|
const stream = await navigator.mediaDevices.getUserMedia({
|
||||||
video: false,
|
video: false,
|
||||||
audio: true,
|
audio: true,
|
||||||
});
|
});
|
||||||
updateState({ audio: true, localStream: stream });
|
updateState({ video: false, audio: true, localStream: stream });
|
||||||
for (const track of stream.getTracks()) {
|
for (const track of stream.getTracks()) {
|
||||||
if (track.kind === 'audio') {
|
if (track.kind === 'audio') {
|
||||||
audioTrack.current = track;
|
audioTrack.current = track;
|
||||||
@ -363,7 +374,9 @@ export function useRingContext() {
|
|||||||
updateState({ video: true });
|
updateState({ video: true });
|
||||||
},
|
},
|
||||||
disableVideo: async () => {
|
disableVideo: async () => {
|
||||||
|
if (videoTrack.current) {
|
||||||
videoTrack.current.enabled = false;
|
videoTrack.current.enabled = false;
|
||||||
|
}
|
||||||
updateState({ video: false });
|
updateState({ video: false });
|
||||||
},
|
},
|
||||||
enableAudio: async () => {
|
enableAudio: async () => {
|
||||||
|
@ -150,15 +150,16 @@ export function useSession() {
|
|||||||
ignore: (call) => {
|
ignore: (call) => {
|
||||||
ring.actions.ignore(call.cardId, call.callId);
|
ring.actions.ignore(call.cardId, call.callId);
|
||||||
},
|
},
|
||||||
decline: (call) => {
|
decline: async (call) => {
|
||||||
ring.actions.decline(call.cardId, call.callId);
|
const { cardId, contactNode, contactToken, callId } = call;
|
||||||
|
await ring.actions.decline(cardId, contactNode, contactToken, callId);
|
||||||
},
|
},
|
||||||
accept: (call) => {
|
accept: async (call) => {
|
||||||
const { cardId, callId, contactNode, contactToken, calleeToken } = call;
|
const { cardId, callId, contactNode, contactToken, calleeToken } = call;
|
||||||
ring.actions.accept(cardId, callId, contactNode, contactToken, calleeToken);
|
await ring.actions.accept(cardId, callId, contactNode, contactToken, calleeToken);
|
||||||
},
|
},
|
||||||
end: async () => {
|
end: async () => {
|
||||||
ring.actions.end();
|
await ring.actions.end();
|
||||||
},
|
},
|
||||||
enableVideo: async () => {
|
enableVideo: async () => {
|
||||||
await ring.actions.enableVideo();
|
await ring.actions.enableVideo();
|
||||||
|
Loading…
Reference in New Issue
Block a user