1
0
mirror of https://github.com/Luzifer/browserphone.git synced 2024-09-19 15:13:00 +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, 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