src/js/bg/plugins/calls/call/sip.js
/**
    * Terminate a Call depending on it's current status.
    */
Terminate a Call depending on it's current status.
Terminate a Call depending on it ' s current status .
terminate() {
        if (this.state.status === 'new') {
            this.module.deleteCall(this)
            return
        } else if (this.state.status === 'create') {
            if (this.session) this.session.terminate()
            this.setState({status: 'request_terminated'})
            this._stop()
        } else {
            try {
                if (this.state.status === 'invite') {
                    this.setState({status: 'request_terminated'})
                    this.session.reject({statusCode: 486})
                } else if (['accepted'].includes(this.state.status)) {
                    this.session.bye()
                    this.setState({status: 'bye'})
                }
            } catch (err) {
                this.app.logger.warn(`${this}unable to close the session properly. (${err})`)
                this._stop()
            }
        }
    }
terminate ( ) { if ( this . state . status === 'new' ) { this . module . deleteCall ( this ) return } else if ( this . state . status === 'create' ) { if ( this . session ) this . session . terminate ( ) this . setState ( { status : 'request_terminated' } ) this . _stop ( ) } else { try { if ( this . state . status === 'invite' ) { this . setState ( { status : 'request_terminated' } ) this . session . reject ( { statusCode : 486 } ) } else if ( [ 'accepted' ] . includes ( this . state . status ) ) { this . session . bye ( ) this . setState ( { status : 'bye' } ) } } catch ( err ) { this . app . logger . warn ( ` ${ this } ${ err } ` ) this . _stop ( ) } } }
Terminate a Call depending on it's current status.
Terminate a Call depending on it ' s current status .
// An empty/new call; just delete the Call object without noise. // A fresh outgoing Call; not yet started. There may or may not // be a session object. End the session if there is one. // The session's closing events will not be called, so manually // trigger the Call to stop here. // Calls with other statuses need some more work to end. // Decline an incoming call with 'Busy Here'. // Hangup a running call. // Set the status here manually, because the bye event on the // session is not triggered. // Get rid of the Call anyway.