Channel event type
After enabling the Notifications service, the Agora server will send a channel event notification callback to your server using the HTTPS POST request method. The data format is JSON, the character encoding is UTF-8, and the signature algorithm is HMAC/SHA1 or HMAC/SHA256.
This page introduces the types and descriptions for all events returned in the channel event callback.
Request parameters
Request header
The notification callback header contains the following fields:
Field | Description |
---|---|
Content-Type | Application/json |
Agora-Signature | The signature value generated by Agora using the customer key and the HMAC/SHA1 algorithm. You need to use the customer key and the HMAC/SHA1 algorithm to verify the signed value. See Add signature verification for details. |
Agora-Signature-V2 | The signature value generated by Agora using the customer key and the HMAC/SHA256 algorithm. You need to use the customer key and the HMAC/SHA256 algorithm to verify the signed value. See Add signature verification for details. |
Request body
The request body of the message notification callback contains the following fields:
Field | Type | Description |
---|---|---|
noticeId | String | Notification ID, identifies an event notification from the Agora business server. |
productId | Number | Business ID, identifies the real-time communication service. |
eventType | Number | The type of the event. See Channel event types for details. |
notifyMs | Number | The Unix timestamp (ms) of the event notification sent by the Agora server to your server. The value is updated when the notification is re-sent. |
sid | String | Session ID. |
payload | JSON Object | The specific content of the event. See Channel event types for details. |
Request example
Channel event types
The Notifications service can notify about the following channel events:
Type | Name | Description |
---|---|---|
101 | channel create | Create a channel. |
102 | channel destroy | Destroy the channel. |
103 | broadcaster join channel | In the live broadcast scenario, the host joins the channel. |
104 | broadcaster leave channel | In the live broadcast scenario, the host leaves the channel. |
105 | audience join channel | In the live broadcast scenario, the audience joins the channel. |
106 | audience leave channel | In the live broadcast scenario, the audience leaves the channel. |
111 | client role change to broadcaster | A member of the audience switches role to become the host. |
112 | client role change to audience | The host switches roles to become a member of the audience. |
channel create
The channel is created, that is, the first user has joined the channel. The payload contains the following fields:
Field | Data type | Description |
---|---|---|
channelName | String | The name of the channel. |
ts | Number | The Unix timestamp(s) indicating when this event occurred on the Agora business server. |
Payload example:
channel destroy
The last user has left the channel and the channel was destroyed. The payload contains the following fields:
Field | Data type | Description |
---|---|---|
channelName | String | The name of the channel. |
ts | Number | The Unix timestamp(s) indicating when this event occurred on the Agora business server. |
lastUid | Number | The ID of the last user to leave the channel. info If multiple users leave the channel at the same time, the Notifications service may return several lastUid s. |
Payload example:
broadcaster join channel
The host has joined the channel in the live broadcast scenario. The payload contains the following fields:
Field | Data type | Description |
---|---|---|
channelName | String | The name of the channel. |
uid | Number | The host’s user ID in the channel. |
platform | Number | The platform of the host's device: 1 : Android, 2 : iOS, 5 : Windows, 6 : Linux, 7 : Web, 8 : macOS, 0 : Other platforms |
clientType | Number | This field is only returned if the platform field returns 6 . The service type used by the viewer side of the Linux platform, common return values include: 3 : Local server recording, 8 : Applets, and 10 : Cloud recording |
clientSeq | Number | Serial number identifying the order in which the events occur on the app client. It can be used to sort events for the same user. For details, see Implement online user status tracking. |
ts | Number | The Unix timestamp(s) indicating when this event occurred on the business server. |
account | String | The user ID. |
Payload example:
broadcaster leave channel
The host has left the channel in the live broadcast scenario. The payload contains the following fields:
Field | Data type | Description |
---|---|---|
channelName | String | The name of the channel. |
uid | Number | The host’s user ID in the channel. |
platform | Number | The platform of the host's device: 1 : Android, 2 : iOS, 5 : Windows, 6 : Linux, 7 : Web, 8 : macOS, 0 : Other platforms |
clientType | Number | This field is only returned if the platform field returns 6 . The service type used by the viewer side of the Linux platform, common return values include: 3 : Local server recording, 8 : Applets, and 10 : Cloud recording |
clientSeq | Number | Serial number identifying the order in which the events occur on the app client. It can be used to sort events for the same user. For details, see Implement online user status tracking. |
reason | Number | The reasons why the host has left the channel:
|
ts | Number | The Unix timestamp(s) indicating when this event occurred on the business server. |
duration | Number | The time that the user has been in the channel. |
account | string | The user ID. |
Payload example:
audience join channel
The members of the audience have joined the channel in the live broadcast scenario. The payload contains the following fields:
Field | Data type | Description |
---|---|---|
channelName | String | The name of the channel. |
uid | Number | The audience’s user ID in the channel. |
platform | Number | The platform of the audience's device: 1 : Android, 2 : iOS, 5 : Windows, 6 : Linux, 7 : Web, 8 : macOS, 0 : Other platforms |
clientType | Number | This field is only returned if the platform field returns 6 . The service type used by the viewer side of the Linux platform, common return values include: 3 : Local server recording, 8 : Applets, and 10 : Cloud recording |
clientSeq | Number | Serial number identifying the order in which the events occur on the app client. It can be used to sort events for the same user. For details, see Implement online user status tracking. |
ts | Number | The Unix timestamp(s) indicating when this event occurred on the business server. |
account | String | The user ID. |
Payload example:
audience leave channel
The members of the audience have left the channel in the live broadcast scenario. The payload contains the following fields:
Field | Data type | Description |
---|---|---|
channelName | String | The name of the channel. |
uid | Number | The audience’s user ID in the channel. |
platform | Number | The platform of the audience's device: 1 : Android, 2 : iOS, 5 : Windows, 6 : Linux, 7 : Web, 8 : macOS, 0 : Other platforms |
clientType | Number | This field is only returned if the platform field returns 6 . The service type used by the viewer side of the Linux platform, common return values include: 3 : Local server recording, 8 : Applets, and 10 : Cloud recording |
clientSeq | Number | Serial number identifying the order in which the events occur on the app client. It can be used to sort events for the same user. For details, see Implement online user status tracking. |
reason | Number | The reasons why the host has left the channel:
|
ts | Number | The Unix timestamp(s) indicating when this event occurred on the business server. |
duration | Number | The time that the user has been in the channel. |
account | string | The user ID. |
Payload example:
client role change to broadcaster
A member of the audience is using the microphone in the live broadcast scenario. The payload contains the following fields:
Field | Data type | Description |
---|---|---|
channelName | String | The name of the channel. |
uid | Number | The host’s user ID in the channel. |
clientSeq | Number | Serial number identifying the order in which the events occur on the app client. It can be used to sort events for the same user. For details, see Implement online user status tracking. |
ts | Number | The Unix timestamp(s) indicating when this event occurred on the business server. |
account | String | The user ID. |
Payload example:
client role change to audience
The host is off the microphone in the live broadcast scenario. The payload contains the following fields:
Field | Data type | Description |
---|---|---|
channelName | String | The name of the channel. |
uid | Number | The audience’s user ID in the channel. |
clientSeq | Number | Serial number identifying the order in which the events occur on the app client. It can be used to sort events for the same user. For details, see Implement online user status tracking. |
ts | Number | The Unix timestamp(s) indicating when this event occurred on the business server. |
account | String | The user ID. |
Payload example: