DeleteChatMessage
Delete the specified chat message. Message must have been from this user. Version must match (or pass -1 to bypass version enforcement).
Returns the number of messages that were deleted. Since the history rolls over, it is possible that the message had already expired before the delete attempt - in that case, the value of the deleted
field will be 0
.
Service | Operation |
---|---|
chat | DELETE_CHAT_MESSAGE |
Method Parameters
Parameter | Description |
---|---|
channelId | The channel of the message |
msgId | The message id |
version | The version of the message. Pass it -1 to bypass version checking. |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string channelId = "22817:gl:CHAT_TRADE"; // APP_ID:CHANNEL_TYPE:CHANNEL_ID
string msgId = "784130333859899";
int version = -1;
SuccessCallback successCallback = (response, cbObject) =>
{
var jsonMessage = (Dictionary<string, object>)JsonFx.Json.JsonReader.Deserialize(response);
Dictionary<string, object> jsonData = (Dictionary<string, object>)jsonMessage["data"];
string deleted = jsonData["deleted"].ToString();
string logMessage = string.Join(" | ", new [] {deleted});
Debug.Log(logMessage); // 1
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("[DeleteChatMessage Failed] {0} {1} {2}", status, code, error));
};
_bc.ChatService.DeleteChatMessage(channelId, msgId, version, successCallback, failureCallback);
const char *channelId = "55555:gl:bcDev";
const char *msgId = "123456789";
int version = 1;
_bc->getChatService()->deleteChatMessage(channelId, msgId, version, this);
NSString *channelId = @"55555:gl:bcDev";
NSString *msgId = @"123456789";
int version = 1;
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc chatService] deleteChatMessage:channelId
msgId:msgId
version:version
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String channelId = "22817:gl:CHAT_TRADE"; // APP_ID:CHANNEL_TYPE:CHANNEL_ID
String msgId = "784130333859899";
int version = -1;
this; // implements IServerCallback
_bc.getChatService().deleteChatMessage(channelId, msgId, version, 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_TRADE";
var msgId = "784130333859899";
var version = -1;
_bc.chat.channelDisconnect(channelId, msgId, version, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var channelId = "22817:gl:CHAT_TRADE";
var msgId = "784130333859899";
var version = -1;
ServerResponse result = await _bc.chatService.channelDisconnect(channelId:channelId, msgId:msgId, version:version);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var chatProxy = bridge.getChatServiceProxy();
var result = chatProxy.deleteChatMessage( channelId, msgId, ver );
{
"service": "chat",
"operation": "DELETE_CHAT_MESSAGE",
"data": {
"channelId": "55555:gl:bcDev",
"msgId": "the-message-id",
"version": 1
}
}
JSON Response
{
"status": 200,
"data": {
"deleted": 1
}
}
Common Error Code
Status Codes
Code | Name | Description |
---|---|---|
40346 | CHAT_INVALID_CHANNEL_ID | The channel id provided is invalid. |
40601 | RTT_NOT_ENABLED | RTT must be enabled for this feature |