Instant Messaging
Set a timer to close a chat room
Update time: 2022/12/13 16:47:07
Chat rooms can be automatically closed by setting a timer.
You can set a countdown timer for closing a chat room when creating a chat room, or call the API described in this document to set a timer.
You have the following two options for closing a chat room:
- Close a chat room after a fixed time period(
delayClosePolicy
= 1): N hours after the chat room is created, it will be closed automatically, regardless of whether participants exist in the chat room. - Close a chat room after the chat room stay idle (
delayClosePolicy
= 2): N hours after no participants exist in the chat room, automatically close the chat room.
- The previous N hours are defined by the
delaySeconds
parameter in the API. Note that the unit in the parameter is seconds. - Timed closure does not happen in real time. Some discrepancies may occur.
Set a countdown timer to close a chat room.
You can change the method to close a chat room by calling this API. If the call is successful, the timer will restart from the current time.
Request URL
POST https://api.netease.im/nimserver/chatroom/updateDelayClosePolicy.action HTTP/1.1
Content-Type: application/x-www-form-urlencoded;charset=utf-8
Request parameters
-
For the setting of Headers in POST requests, seeAPI Calling.
-
The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
roomid | Long | Yes | Chat room ID |
delayClosePolicy | Integer | No |
Timer option. 0: no timer, 1: set a timer to close the chat room regardless of whether participants exist in the chat room, 2: set a timer to close the chat room when no participants exist in the chat room |
delaySeconds | Long | No |
The timer to close the chat room. |
Response parameters
Parameter | Type | Description | |
---|---|---|---|
code | Integer | Status code | |
roomid | Long | Chat room ID | |
valid | Boolean | false: close a chat room, true: open a chat room | |
announcement | String | Announcement in a chat room | |
name | String | The name of a chat room | |
broadcasturl | String | URL for live streaming | |
ext | String | Extension field | |
queuelevel | Integer | Queue management permission. 0: All participants have the permission to change a queue, 1: Only hosts and administrators have the permission to change a queue | |
muted | Boolean | Whether the chat room is all muted. Only administrators and creators can speak if a chat room is all muted. false: unmuted, true: muted | |
creator | String | ID of the creator | |
delayInfo | String | Timer info | |
delayCloseEnable | Boolean | Whether a timer is enabled, true: enabled, false: disabled | |
delayClosePolicy | Integer | Method to close a chat room. 0: no timer, 1: close a chat room when the timer ends, 2: close a chat room if no participants exist in the chat room | |
delaySeconds | Long | Timer period. The maximum period (7*24*3600s) | |
status | Integer | Current status, 1: The task starts in the initial state, 2: waiting state, 3: task completion state, 4: task canceled< /td> | |
startTime | Long | Timestamp of the start time |
Example
cURL request
curl -X POST -i 'https://api.netease.im/nimserver/chatroom/updateDelayClosePolicy.action' -H "Nonce: 12345" -H "CheckSum: 54871a1f9a695bba5d42c04e727e6423c87fa728" -H "AppKey: 2bd025c577313e81b2bdb2d2dcefcadb" -H "CurTime: 1666597250" -d 'roomid=1600849147&delayClosePolicy=2&delaySeconds=60'
Example success response
"Content-Type": "application/json; charset=utf-8"
{
"code": 200,
"chatroom": {
"valid": true,
"ext": "",
"creator": "test100",
"name": "test1-chatroom",
"muted": false,
"announcement": null,
"broadcasturl": "xxxxxx",
"roomid": 1600849147,
"queuelevel": 0,
"delayInfo": {
"delaySeconds": 60,
"delayCloseEnable": true,
"startTime": 1666597250262,
"delayClosePolicy": 2,
"status": 2
}
}
}
Example error response
"Content-Type": "application/json; charset=utf-8"
{
"code": 414,
"desc": "owner not register"
}
Status codes
The following status codes are related to responses of this API. For more status codes, see Status codes.
Status code | Description | Recommendation |
---|---|---|
200 | Success | - |
414 | Parameter error | Check the format and restrictions of arguments based on the error message |
403 | Forbidden operation | The chat room name failed to pass the moderation or the chat room permission is not granted |
404 | Chat room does not exist | Check the chat room ID |
419 | The number of chat rooms exceeds the upper limit | - |
13009 | The timer for closing a chat room is disabled | It is recommended to enable the timer |
13002 | The chat room is already closed | Open or recreate the chat room |
Was this topic helpful?
Yes
No