mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19: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
|
||||
callerToken := hex.EncodeToString(callerBin);
|
||||
calleeToken := hex.EncodeToString(calleeBin);
|
||||
bridgeRelay.AddBridge(account.ID, callId, callerToken, calleeToken);
|
||||
bridgeRelay.AddBridge(account.ID, callId, cardId, callerToken, calleeToken);
|
||||
|
||||
// create response
|
||||
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
|
||||
}
|
||||
|
||||
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()
|
||||
defer s.sync.Unlock()
|
||||
bridge := &Bridge{
|
||||
accountId: accountId,
|
||||
callId: callId,
|
||||
cardId: cardId,
|
||||
expires: time.Now().Unix() + (BridgeKeepAlive * 3),
|
||||
closed: false,
|
||||
callerToken: callerToken,
|
||||
|
@ -815,7 +815,7 @@ var endpoints = routes{
|
||||
"EndCall",
|
||||
strings.ToUpper("Delete"),
|
||||
"/talk/calls/{callId}",
|
||||
EndCall,
|
||||
RemoveCall,
|
||||
},
|
||||
|
||||
route{
|
||||
|
@ -64,13 +64,19 @@ export function useRingContext() {
|
||||
updateState({ ringing: ringing.current });
|
||||
}
|
||||
},
|
||||
decline: (cardId, callId) => {
|
||||
decline: async (cardId, contactNode, contactToken, callId) => {
|
||||
const key = `${cardId}:${callId}`
|
||||
const call = ringing.current.get(key);
|
||||
if (call) {
|
||||
call.status = 'declined'
|
||||
ringing.current.set(key, call);
|
||||
updateState({ ringing: ringing.current });
|
||||
try {
|
||||
await removeContactCall(contactNode, contactToken, callId);
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
},
|
||||
accept: async (cardId, callId, contactNode, contactToken, calleeToken) => {
|
||||
@ -121,7 +127,10 @@ export function useRingContext() {
|
||||
// handle messages [impolite]
|
||||
try {
|
||||
const signal = JSON.parse(ev.data);
|
||||
if (signal.description) {
|
||||
if (signal.status === 'closed') {
|
||||
ws.current.close();
|
||||
}
|
||||
else if (signal.description) {
|
||||
stream.current = null;
|
||||
if (signal.description.type === 'offer' && pc.current.signalingState !== 'stable') {
|
||||
return; //rudely ignore
|
||||
@ -262,12 +271,14 @@ export function useRingContext() {
|
||||
}
|
||||
};
|
||||
|
||||
videoTrack.current = false;
|
||||
audioTrack.current = false;
|
||||
accessVideo.current = false;
|
||||
const stream = await navigator.mediaDevices.getUserMedia({
|
||||
video: false,
|
||||
audio: true,
|
||||
});
|
||||
updateState({ audio: true, localStream: stream });
|
||||
updateState({ video: false, audio: true, localStream: stream });
|
||||
for (const track of stream.getTracks()) {
|
||||
if (track.kind === 'audio') {
|
||||
audioTrack.current = track;
|
||||
@ -363,7 +374,9 @@ export function useRingContext() {
|
||||
updateState({ video: true });
|
||||
},
|
||||
disableVideo: async () => {
|
||||
videoTrack.current.enabled = false;
|
||||
if (videoTrack.current) {
|
||||
videoTrack.current.enabled = false;
|
||||
}
|
||||
updateState({ video: false });
|
||||
},
|
||||
enableAudio: async () => {
|
||||
|
@ -150,15 +150,16 @@ export function useSession() {
|
||||
ignore: (call) => {
|
||||
ring.actions.ignore(call.cardId, call.callId);
|
||||
},
|
||||
decline: (call) => {
|
||||
ring.actions.decline(call.cardId, call.callId);
|
||||
decline: async (call) => {
|
||||
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;
|
||||
ring.actions.accept(cardId, callId, contactNode, contactToken, calleeToken);
|
||||
await ring.actions.accept(cardId, callId, contactNode, contactToken, calleeToken);
|
||||
},
|
||||
end: async () => {
|
||||
ring.actions.end();
|
||||
await ring.actions.end();
|
||||
},
|
||||
enableVideo: async () => {
|
||||
await ring.actions.enableVideo();
|
||||
|
Loading…
Reference in New Issue
Block a user