GetChatMessage
Retrieves a chat message object from history. If the message cannot be found, that data
section returned will be empty.
Service | Operation |
---|---|
chat | GET_CHAT_MESSAGE |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string channelId = "22817:gl:CHAT_GROUPFINDER"; // APP_ID:CHANNEL_TYPE:CHANNEL_ID
string msgId = "783820066133040";
SuccessCallback successCallback = (response, cbObject) =>
{
Dictionary<string, object> jsonMessage = (Dictionary<string, object>)JsonFx.Json.JsonReader.Deserialize(response);
Dictionary<string, object> jsonData = (Dictionary<string, object>)jsonMessage["data"];
var date = jsonData["date"].ToString();
var name = ((Dictionary<string, object>)jsonData["from"])["name"].ToString();
var text = ((Dictionary<string, object>)jsonData["content"])["text"].ToString();
string logMessage = string.Join(" | ", new [] {date, name, text});
Debug.Log(logMessage); // 1530898566666 | RedBomber | Anyone looking for a group?
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("[GetChatMessage Failed] {0} {1} {2}", status, code, error));
};
_bc.ChatService.GetChatMessage(channelId, msgId, successCallback, failureCallback);
const char *channelId = "55555:gl:bcDev";
const char *msgId = "123456789";
_bc->getChatService()->getChatMessage(channelId, msgId, this);
NSString *channelId = @"55555:gl:bcDev";
NSString *msgId = @"123456789";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc chatService] getChatMessage:channelId
msgId:msgId
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String channelId = "22817:gl:CHAT_GROUPFINDER"; // APP_ID:CHANNEL_TYPE:CHANNEL_ID
String msgId = "783820066133040";
this; // implements IServerCallback
_bc.getChatService().getChatMessage(channelId, msgId, this);
public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData)
{
System.out.print(String.format("Success | %s", jsonData.toString()));
}
public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError)
{
System.out.print(String.format("Failed | %d %d %s", statusCode, reasonCode, jsonError.toString()));
}
var channelId = "22817:gl:CHAT_GROUPFINDER"; // APP_ID:CHANNEL_TYPE:CHANNEL_ID
var msgId = "783820066133040";
_bc.chat.getChatMessage(channelId, msgId, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var channelId = "22817:gl:CHAT_GROUPFINDER";
var msgId = "783820066133040";
ServerResponse result = await _bc.chatService.getChatMessage(channelId:channelId, msgId:msgId);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var chatProxy = bridge.getChatServiceProxy();
var getResult = chatProxy.getChatMessage(channelId, msgId);
if (getReult.status == 200 ) {
msgText = getResult.data.content.text;
}
{
"service": "chat",
"operation": "GET_CHAT_MESSAGE",
"data": {
"channelId": "55555:gl:bcDev",
"msgId": "the-message-id"
}
}
JSON Response
{
"data": {
"date": 1530898566666,
"ver": 1,
"msgId": "783820066133040",
"from": {
"id": "a7b7de02-8432-4547-8c40-9af94537fce0",
"name": "RedBomber",
"pic": null
},
"chId": "22817:gl:CHAT_TRADE",
"content": {
"text": "Anyone looking for a group?"
}
},
"status": 200
}
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 |
Method Parameters
Parameter | Description |
---|---|
channelId | The channel of the message |
msgId | The message id |