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:
parent
6669ccf26e
commit
a6edf63c49
1 changed files with 13 additions and 0 deletions
13
src/app.vue
13
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
|
||||
|
|
Loading…
Reference in a new issue