GetChannelId
Retrieves a channel id given the specified lookup parameters.
Service | Operation |
---|---|
chat | GET_CHANNEL_ID |
Method Parameters
Parameter | Description |
---|---|
channelType | The channel type - ‘gl’ for global, ‘gr’ for groups, ‘dy’ for dynamic. |
channelSubId | The type-specific sub id |
Usage
http://localhost:3000
- C#
- C++
- Objective-C
- Java
- JavaScript
- Dart
- Cloud Code
- Raw
string channelType = "gl";
string channelSubId = "CHAT_TRADE";
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 channelId = jsonData["channelId"].ToString();
string logMessage = string.Join(" | ", new [] {channelId});
Debug.Log(logMessage); // 22817:gl:CHAT_TRADE
};
FailureCallback failureCallback = (status, code, error, cbObject) =>
{
Debug.Log(string.Format("[GetChannelId Failed] {0} {1} {2}", status, code, error));
};
_bc.ChatService.GetChannelId(channelType, channelSubId, successCallback, failureCallback);
const char *channelType = "gl";
const char *channelSubId = "myChatRoom";
_bc->getChatService()->getChannelId(channelType, channelSubId, this);
NSString *channelType = @"gl";
NSString *channelSubId = @"myChatRoom";
BCCompletionBlock successBlock; // define callback
BCErrorCompletionBlock failureBlock; // define callback
[[_bc chatService] getChannelId:channelType
channelSubId:channelSubId
completionBlock:successBlock
errorCompletionBlock:failureBlock
cbObject:nil];
String channelType = "gl";
String channelSubId = "CHAT_TRADE";
this; // implements IServerCallback
_bc.getChatService().getChannelId(channelType, channelSubId, 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 channelType = "gl";
var channelSubId = "CHAT_TRADE";
_bc.chat.getChannelId(channelType, channelSubId, result =>
{
var status = result.status;
console.log(status + " : " + JSON.stringify(result, null, 2));
});
var channelType = "gl";
var channelSubId = "CHAT_TRADE";
ServerResponse result = await _bc.chatService.getChannelId(channelType:channelType, channelSubId:channelSubId);
if (result.statusCode == 200) {
print("Success");
} else {
print("Failed ${result.error['status_message'] ?? result.error}");
}
var chatProxy = bridge.getChatServiceProxy();
var idResult = proxy.getChannelId( 'gl', 'bcChat');
if (idResult.status == 200 ) {
channelId = idResult.data.channelId;
}
{
"service": "chat",
"operation": "GET_CHANNEL_ID",
"data": {
"channelType": "gl",
"channelSubId": "myChatRoom"
}
}
JSON Response
{
"status": 200,
"data": {
"channelId": "22817:gl:CHAT_TRADE"
}
}
Common Error Code
Status Codes
Code | Name | Description |
---|---|---|
40601 | RTT_NOT_ENABLED | RTT must be enabled for this feature |
40603 | CHAT_UNRECOGNIZED_CHANNEL | The sub id for the channel type is not recognized |