回调事件参考(101-112 / 201-203)
构建时从公开回调事件定义生成:事件码、名称、触发时机与负载字段。
事件信封
每次投递是一个 JSON 对象,字段由 公开接口定义(schema nimeet.callbacks v1.0.0)定义:
| 字段 | 类型 / 含义 |
|---|---|
eventType | number — see events[].eventType |
noticeId | string — unique per delivery attempt batch |
notifyMs | epoch milliseconds when the event was produced |
payload | object — event specific, see events[].payload |
productId | number — 1 = RTC |
sid | string — unique session id for the event |
{
"eventType": 101,
"noticeId": "ntc_01J8Z0000000000000000000AA",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_01J8Z0000000000000000000AA",
"payload": {
"channelName": "weekly-sync",
"profile": "communication",
"ts": 1771000000
}
}事件码全表(自动生成)
共 13 个事件,事件码与声网频道事件(101–112)及任务事件(201–203)对齐;负载字段逐项取自回调事件定义。
频道与用户事件
| 事件码 | 名称 | 触发时机 |
|---|---|---|
101 | channel_create | Channel created (first participant joins or room is created). |
102 | channel_destroy | Channel destroyed (room finished / last participant left and grace elapsed). |
103 | broadcaster_join | A broadcaster (host) joined a live channel. |
104 | broadcaster_leave | A broadcaster left a live channel; `reason` carries the Agora leave reason. |
105 | audience_join | An audience member joined a live channel. |
106 | audience_leave | An audience member left a live channel. |
107 | user_join | A user joined a communication channel. |
108 | user_leave | A user left a communication channel; `reason` carries the Agora leave reason. |
111 | role_to_broadcaster | A user was promoted to broadcaster/host. |
112 | role_to_audience | A user was demoted to audience. |
任务与 Token 事件
| 事件码 | 名称 | 触发时机 |
|---|---|---|
201 | recording_state_changed | Cloud recording task state changed (starting/running/stopping/stopped/failed). |
202 | streaming_state_changed | Bypass streaming task state changed (including idle-timeout expiry). |
203 | token_expiring | A token is close to its privilege expiry; `TOKEN_PRIVILEGE_WILL_EXPIRE_LEAD_SECONDS` lead time. |
事件负载字段
101 channel_create
Channel created (first participant joins or room is created).
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
profile | communication | live |
ts | epoch seconds |
{
"eventType": 101,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"profile": "…",
"ts": 1771000000
}
}102 channel_destroy
Channel destroyed (room finished / last participant left and grace elapsed).
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
ts | epoch seconds |
{
"eventType": 102,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"ts": 1771000000
}
}103 broadcaster_join
A broadcaster (host) joined a live channel.
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
platform | number |
ts | epoch seconds |
uid | number |
{
"eventType": 103,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"platform": 1,
"ts": 1771000000,
"uid": 10001
}
}104 broadcaster_leave
A broadcaster left a live channel; `reason` carries the Agora leave reason.
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
reason | number |
ts | epoch seconds |
uid | number |
{
"eventType": 104,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"reason": 1,
"ts": 1771000000,
"uid": 10001
}
}105 audience_join
An audience member joined a live channel.
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
platform | number |
ts | epoch seconds |
uid | number |
{
"eventType": 105,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"platform": 1,
"ts": 1771000000,
"uid": 10001
}
}106 audience_leave
An audience member left a live channel.
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
reason | number |
ts | epoch seconds |
uid | number |
{
"eventType": 106,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"reason": 1,
"ts": 1771000000,
"uid": 10001
}
}107 user_join
A user joined a communication channel.
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
platform | number |
ts | epoch seconds |
uid | number |
{
"eventType": 107,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"platform": 1,
"ts": 1771000000,
"uid": 10001
}
}108 user_leave
A user left a communication channel; `reason` carries the Agora leave reason.
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
reason | number |
ts | epoch seconds |
uid | number |
{
"eventType": 108,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"reason": 1,
"ts": 1771000000,
"uid": 10001
}
}111 role_to_broadcaster
A user was promoted to broadcaster/host.
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
ts | epoch seconds |
uid | number |
{
"eventType": 111,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"ts": 1771000000,
"uid": 10001
}
}112 role_to_audience
A user was demoted to audience.
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
ts | epoch seconds |
uid | number |
{
"eventType": 112,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"ts": 1771000000,
"uid": 10001
}
}201 recording_state_changed
Cloud recording task state changed (starting/running/stopping/stopped/failed).
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
mode | composite | individual | web |
state | string |
taskId | string |
ts | epoch seconds |
{
"eventType": 201,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"mode": "…",
"state": "running",
"taskId": "task_…",
"ts": 1771000000
}
}202 streaming_state_changed
Bypass streaming task state changed (including idle-timeout expiry).
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
hlsUrl | string |
rtmpUrl | string |
state | string |
taskId | string |
ts | epoch seconds |
{
"eventType": 202,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"hlsUrl": "…",
"rtmpUrl": "…",
"state": "running",
"taskId": "task_…",
"ts": 1771000000
}
}203 token_expiring
A token is close to its privilege expiry; `TOKEN_PRIVILEGE_WILL_EXPIRE_LEAD_SECONDS` lead time.
| 字段 | 类型 / 取值 |
|---|---|
channelName | string |
privilegeExpireAt | epoch seconds |
ts | epoch seconds |
uid | number |
{
"eventType": 203,
"noticeId": "ntc_…",
"notifyMs": 1771000000000,
"productId": 1,
"sid": "sid_…",
"payload": {
"channelName": "weekly-sync",
"privilegeExpireAt": 1771000000,
"ts": 1771000000,
"uid": 10001
}
}请求头与签名
| 请求头 | 说明 |
|---|---|
Agora-Signature | HMAC-SHA1 hex of the raw body with the endpoint secret |
Agora-Signature-V2 | HMAC-SHA256 hex of the raw body with the endpoint secret |
Content-Type | application/json |
X-Request-Id | delivery correlation id |
接收方必须用原始请求体字节计算签名:先反序列化再签名会把空格/顺序差异算进去,导致校验失败。校验与重放防护的完整实现见 回调接入。
重试与成功判据
| 项 | 值 |
|---|---|
| 最大尝试次数 | 9 |
| 退避序列(秒) | 5 / 15 / 60 / 300 / 900 / 3600 / 7200 / 21600 |
| 成功判据 | HTTP 2xx |
| 幂等键 | noticeId(重复投递保持不变) |
非 2xx 视为失败并进入下一次退避;耗尽重试后投递记录保留在投递日志里,可通过控制台或 投递日志接口重放。