SysGetRecentChatMessages
tip
This method is available in Cloud Code scripts only.
Returns a list of max \<n> messages from history.
Service | Operation |
---|---|
chat | SYS_GET_RECENT_CHAT_MESSAGES |
Method Parameters
Parameter | Description |
---|---|
channelId | The chat channel to retrieve messages from |
maxReturn | Maximum number of messages to return |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
// Cloud Code only. To view example, switch to the Cloud Code tab
var channelId = "55555:gl:bcDev";
var maxReturn = 25;
var chatProxy = bridge.getChatServiceProxy();
var postResult = chatProxy.sysGetRecentChatMessages(channelId, maxReturn);
if (postResult.status == 200) {
// Success!
}
{
"service": "chat",
"operation": "SYS_GET_RECENT_CHAT_MESSAGES",
"data": {
"channelId": "55555:gl:bcDev",
"maxReturn": 25
}
}
JSON Response
{
"status": 200,
"data": {
"messages": [
{
"date": 1529947494687,
"ver": 1,
"msgId": "783333117279792",
"from": {
"id": "f0bdf734-f5ed-4617-8f40-62795dc82932",
"name": "Paul Winterhalder",
"pic": null
},
"chId": "55555:gl:brainCloudDev",
"content": {
"text": "This is a test"
}
},
{
"date": 1529948166604,
"ver": 1,
"msgId": "783333461301297",
"from": {
"id": "3b87aaa8-b47a-4096-9809-ce0da77ae60d",
"name": "",
"pic": null
},
"chId": "55555:gl:brainCloudDev",
"content": {
"text": "Hello world"
}
}
]
}
}
Common Error Code
Status Codes
Code | Name | Description |
---|---|---|
40601 | RTT_NOT_ENABLED | RTT must be enabled for this feature |
40603 | CHAT_UNRECOGNIZED_CHANNEL | The specified channel is invalid |
40616 | CLOUD_CODE_ONLY | Method only available via cloud code |