The following documentation involves events that are related to disconnecting:

- When is the User Considered Disconnected?
- Special Disconnect Cases
- Expected Disconnection Behaviour
- Limitation #1
- Limitation #2
- Notes

When is the User Considered Disconnected?

The user is considered disconnected if:

1. the user hangs up
2. the interpreter encounters a `<disconnect>` and disconnects the user (currently, the user is not considered disconnected in this case).
3. the user is transfered to another phone number using `<transfer bridge="false"/>`

In the first two cases, the `telephone.disconnect.hangup` event is thrown; in the third case, the `telephone.disconnect.transfer` event is thrown.

Special Disconnect Cases

Case 1: A disconnect occurs (the user hangs up) while a VoiceXML page is in the process of being fetched for one of the following tags:

- `<choice>`
- `<goto>`
- `<link>`
- `<subdialog>`
- `<submit>`

Behaviour:

1. The interpreter will wait until it has finished fetching the second page, but will not compile it.
2. The interpreter will throw the `telephone.disconnect.hangup` event in the original page, not the fetched page. The event will be thrown in the same scope as the `<goto>`, `<link>`, `<subdialog>`, or `<submit>` in the original page. Note that the fetched VoiceXML page will not be executed.

Case 2: A disconnect occurs (the user hangs up) during the fetch of the initial page.

Behaviour:

The interpreter will wait for the initial page to be returned, compile it, and then throw the `telephone.disconnect.hangup`/`connection.disconnect.hangup` event upon entering the initial page.

Expected Disconnection Behaviour

The application can define `<catch>` event handlers to process the disconnect event. According to the VoiceXML specification:

> "Under certain circumstances (in particular, while the VoiceXML interpreter is processing a disconnect event) the interpreter may continue executing in the final processing state after there is no longer a connection to allow the interpreter to interact with the end user. The purpose of this state is to allow the VoiceXML application to perform any necessary final cleanup, such as submitting information to the application server... The VoiceXML interpreter must exit if the VoiceXML application [encounters an input tag] while in the final processing state. Aside from this restriction, execution of the VoiceXML application continues normally while in the final processing state [until the end of the application is reached]."

Note: In the executed `<catch>` event handler, the `event` attribute will be any of: `telephone`, `telephone.disconnect`, `telephone.disconnect.hangup`, or `telephone.disconnect.transfer`, depending on which event handlers are defined in the application, and which one first matches (or first matches a prefix of) the disconnect event that was thrown.

Notes

1. If a developer throws `telephone.disconnect.hangup` in an application, it will simply be treated as a developer-defined event. Throwing the event will not cause the call to actually be disconnected.