From a6edf63c496f3c0bd39135ec671eda822a27b1a8 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 10 Jun 2019 21:59:00 +0200 Subject: [PATCH] Add ringing state Signed-off-by: Knut Ahlers --- src/app.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app.vue b/src/app.vue index ee21d31..5207d77 100644 --- a/src/app.vue +++ b/src/app.vue @@ -74,6 +74,7 @@ export default { conn: null, device: null, }, + ringing: false, state: '', } }, @@ -104,6 +105,7 @@ export default { this.phone.device.on('connect', conn => { this.phone.conn = conn this.ongoingCall = true + this.ringing = false this.announeState('Call connected') }) this.phone.device.on('disconnect', () => { @@ -111,6 +113,11 @@ export default { this.ongoingCall = false this.announeState('Call disconnected') }) + this.phone.device.on('incoming', conn => { + this.announceStatus(`Incoming call from ${conn.parameters.From}`) + this.phone.conn = conn + this.ringing = true + }) this.phone.device.on('offline', () => { this.announceStatus('Phone disconnected, reconnecting...') this.setupPhone() @@ -123,11 +130,17 @@ export default { .then(resp => { this.identity = resp.data.identity this.phone.device.setup(resp.data.token, opts) + this.ringing = false }) .catch(err => console.error(err)) }, toggleCall() { + if (this.ringing && this.phone.conn) { + this.phone.conn.accept() + return + } + if (this.ongoingCall) { this.phone.device.disconnectAll() return