mirror of
https://github.com/Luzifer/browserphone.git
synced 2024-11-09 22:30:09 +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,
|
conn: null,
|
||||||
device: null,
|
device: null,
|
||||||
},
|
},
|
||||||
|
ringing: false,
|
||||||
state: '',
|
state: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -104,6 +105,7 @@ export default {
|
||||||
this.phone.device.on('connect', conn => {
|
this.phone.device.on('connect', conn => {
|
||||||
this.phone.conn = conn
|
this.phone.conn = conn
|
||||||
this.ongoingCall = true
|
this.ongoingCall = true
|
||||||
|
this.ringing = false
|
||||||
this.announeState('Call connected')
|
this.announeState('Call connected')
|
||||||
})
|
})
|
||||||
this.phone.device.on('disconnect', () => {
|
this.phone.device.on('disconnect', () => {
|
||||||
|
@ -111,6 +113,11 @@ export default {
|
||||||
this.ongoingCall = false
|
this.ongoingCall = false
|
||||||
this.announeState('Call disconnected')
|
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.phone.device.on('offline', () => {
|
||||||
this.announceStatus('Phone disconnected, reconnecting...')
|
this.announceStatus('Phone disconnected, reconnecting...')
|
||||||
this.setupPhone()
|
this.setupPhone()
|
||||||
|
@ -123,11 +130,17 @@ export default {
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
this.identity = resp.data.identity
|
this.identity = resp.data.identity
|
||||||
this.phone.device.setup(resp.data.token, opts)
|
this.phone.device.setup(resp.data.token, opts)
|
||||||
|
this.ringing = false
|
||||||
})
|
})
|
||||||
.catch(err => console.error(err))
|
.catch(err => console.error(err))
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleCall() {
|
toggleCall() {
|
||||||
|
if (this.ringing && this.phone.conn) {
|
||||||
|
this.phone.conn.accept()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (this.ongoingCall) {
|
if (this.ongoingCall) {
|
||||||
this.phone.device.disconnectAll()
|
this.phone.device.disconnectAll()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue