Describes the connection state machine of the AOQ Client SDK and the corresponding API calls.
Connection state diagram
The following diagram shows the connection state transitions of the AOQ Client SDK:
AOQ Client SDK connection state diagram
State descriptions
State | Enum value | Description |
|---|---|---|
Connecting | 1 | Entered after calling |
Connected | 2 | Connection established. Audio, video, and data messages can be sent and received normally. |
Failed | 3 | Connection error (authentication failure, timeout, server rejection, and so on). The SDK automatically transitions to Disconnected. |
Disconnected | 0 | Initial state, or the terminal state after an intentional or unexpected disconnection. |
State transition rules
- App calls
connect→ entersConnecting. - Connection succeeds → transitions from
ConnectingtoConnected. - Connection fails → transitions from
ConnectingtoFailed, then the SDK automatically transitions toDisconnected. - Connection fails → transitions from
ConnectedtoFailed, then the SDK automatically transitions toDisconnected. - App calls
disconnect→ transitions fromConnectedtoDisconnected.
Failed is a transient state. After the SDK fires onConnectionStatusChange(Failed), it automatically transitions to Disconnected. The application layer does not need to call disconnect manually.
connect API
Call connect to initiate a connection to the AI Service. Pass the authentication credentials returned by the AppServer allocate endpoint.
Method signature
Android:
0 indicates the call succeeded (connection is established asynchronously). < 0 indicates failure.
Behavior
- Fires the
onConnectionStatusChange(connecting)callback immediately after the call. - Fires the
onConnectionStatusChange(connected)callback if the connection succeeds. - Fires the
onConnectionStatusChange(failed)callback if the connection fails.
disconnect API
Call disconnect to intentionally close the connection to the AI Service.
Method signature
Android:
0 indicates success. < 0 indicates failure.
Behavior
- Fires the
onConnectionStatusChange(Disconnected)callback after the call. - The engine is not released automatically. You can call
connectagain to reconnect. - Calling
disconnectwhen not connected is safe and returns 0.