diff --git a/frontend/pages/communication/phone.vue b/frontend/pages/communication/phone.vue index 0ed50a8..89e2f22 100644 --- a/frontend/pages/communication/phone.vue +++ b/frontend/pages/communication/phone.vue @@ -23,6 +23,17 @@ const sipError = ref(null) const incomingCall = ref(null) const callState = ref("idle") const registererState = ref("Initial") +const sipEvents = ref([]) + +const addSipEvent = (message) => { + sipEvents.value = [ + { + time: new Date().toLocaleTimeString("de-DE"), + message, + }, + ...sipEvents.value, + ].slice(0, 8) +} const selectedAccount = computed(() => (config.value?.testAccounts || []).find((account) => account.extension === selectedExtension.value) @@ -254,6 +265,7 @@ const registerSip = async () => { if (!uri) throw new Error("SIP-URI konnte nicht erstellt werden.") const handleIncomingInvite = (invitation) => { + addSipEvent(`INVITE von ${invitation.remoteIdentity?.uri?.user || "unbekannt"} empfangen`) incomingCall.value = invitation setupSession(invitation, "incoming") @@ -270,18 +282,37 @@ const registerSip = async () => { contactName: account.extension, authorizationUsername: account.extension, authorizationPassword: account.password, + logBuiltinEnabled: true, + logLevel: "log", + logConnector: (level, category, label, content) => { + if (category === "sip.Transport" && content.includes("Received WebSocket")) { + addSipEvent("SIP-Nachricht über WebSocket empfangen") + } + + if (content.includes("INVITE")) { + addSipEvent(`${category}: ${content.split("\n")[0]}`) + } + + if (level === "error" || level === "warn") { + addSipEvent(`${category}: ${content.split("\n")[0]}`) + } + }, delegate: { onInvite: handleIncomingInvite, onConnect: () => { + addSipEvent("SIP-WebSocket verbunden") sipStatus.value = sipRegistered.value ? `Registriert als ${account.extension}` : "SIP-WebSocket verbunden" }, onDisconnect: () => { + addSipEvent("SIP-WebSocket getrennt") sipRegistered.value = false sipStatus.value = "SIP-WebSocket getrennt" }, }, transportOptions: { server: config.value.sipWebSocketUrl, + keepAliveInterval: 20, + traceSip: true, }, sessionDescriptionHandlerFactoryOptions: { constraints: { @@ -302,11 +333,13 @@ const registerSip = async () => { registererState.value = state if (state === sip.RegistererState.Registered) { + addSipEvent(`Registrierung ${account.extension}: Registered`) sipRegistered.value = true sipStatus.value = `Registriert als ${account.extension}` } if (state === sip.RegistererState.Unregistered || state === sip.RegistererState.Terminated) { + addSipEvent(`Registrierung ${account.extension}: ${state}`) sipRegistered.value = false sipStatus.value = "Nicht verbunden" } @@ -319,6 +352,7 @@ const registerSip = async () => { await reg.register({ requestDelegate: { onAccept: () => { + addSipEvent(`REGISTER ${account.extension}: 200 OK`) sipRegistered.value = true sipStatus.value = `Registriert als ${account.extension}` registererState.value = sip.RegistererState.Registered @@ -327,6 +361,7 @@ const registerSip = async () => { sipRegistered.value = false sipStatus.value = "Registrierung abgelehnt" sipError.value = `Asterisk hat REGISTER mit HTTP/SIP ${response.message.statusCode} abgelehnt.` + addSipEvent(`REGISTER ${account.extension}: ${response.message.statusCode}`) }, }, }) @@ -576,6 +611,25 @@ onBeforeUnmount(() => { +
+

+ SIP-Ereignisse +

+ +
+