1
0
Fork 0
mirror of https://github.com/Luzifer/browserphone.git synced 2024-11-09 14:20:04 +00:00

Add ringing state

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2019-06-10 21:59:00 +02:00
parent 6669ccf26e
commit a6edf63c49
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -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