대화 그룹
Overview
In some cases, you may need to group conversations, for example, into a "Product experience" or "R&D" group, which can be implemented through the following API.
Note
To use this feature, you need to purchase the Premium edition.
This feature is supported only on the enhanced edition on native SDK 6.5 or later.
Conversation Group
Creating a conversation group
Note
Up to 20 conversation groups can be created. After this limit is exceeded, the
51010
error will be reported. Groups that are no longer used should be promptly deleted.Attribute | Definition | Description |
groupName | Conversation group name | It must be greater than 0 in length and can contain up to 32 bytes; otherwise, the 51011 error will be reported. |
conversationIDList | List of conversation IDs | It cannot be empty. |
Sample code:
// Create a conversation groupTIMResult res = TencentIMSDK.ConvCreateConversationGroup("groupName", new List<string> {conv_id}, (int code, string desc, List<ConversationOperationResult> results, string user_data)=>{// Async result of the conversation group creation});
Deleting a conversation group
Note
If the target conversation group doesn't exist, the
51009
error will be reported.Sample code:
// Delete the conversation groupTIMResult res = TencentIMSDK.ConvDeleteConversationGroup("groupName", (int code, string desc, string result, string user_data)=>{// Async result of the conversation group deletion});
Renaming a conversation group
Sample code:
// Rename a conversation groupTIMResult res = TencentIMSDK.ConvRenameConversationGroup("oldGroupName", "newGroupName", (int code, string desc, string result, string user_data)=>{// Async result of the conversation group renaming});
Getting the list of conversation groups
Sample code:
// Get the list of conversation groupsTIMResult res = TencentIMSDK.ConvGetConversationGroupList((int code, string desc, List<string> results, string user_data)=>{// Async result of the conversation group list getting});
To get the list of conversations under a group, you can call the
ConvGetConversationListByFilter
(details) API.Sample code:
// Get the conversation listConversationListFilter filter = new ConversationListFilter{conversation_list_filter_conv_type: TIMConvType.kTIMConv_C2C,// Conversation typeconversation_list_filter_mark_type: TIMConversationMarkType.kTIMConversationMarkTypeStar,// Conversation mark typeconversation_list_filter_conversation_group: "groupName"// Named of the group whose data is to be pulled};ulong next_seq = 0; // Pulling cursoruint count = 10; // Pulling count// Advanced API for getting the conversation listTIMResult res = TencentIMSDK.ConvGetConversationListByFilter(filter, next_seq, count, (int code, string desc, ConversationListResult result, string user_data)=>{// Async result of the conversation list gettingif (code == 0) {// Pulled successfullybool isFinished = result.conversation_list_result_is_finished; // Whether pulling is completednext_seq = result.conversation_list_result_next_seq; // Cursor for subsequent paged pullingvar conversationList = result.conversation_list_result_conv_list; // List of messages pulled this time// If more conversations need to be pulled, use the returned `nextSeq` to continue pulling until `isFinished` is `true`.}});
Adding a conversation to a group
After a group is created, you can call the
ConvAddConversationsToGroup
(details) API to add a conversation to the group.Sample code:
// Add a conversation to a conversation groupTIMResult res = TencentIMSDK.ConvAddConversationsToGroup("groupName", new List<string> {conv_id}, (int code, string desc, List<ConversationOperationResult> results, string user_data)=>{// Async result of adding a conversation to a conversation group});
Deleting a conversation from a group
Sample code:
// Delete a conversation from a conversation groupTIMResult res = TencentIMSDK.ConvDeleteConversationsFromGroup("groupName", new List<string> {conv_id}, (int code, string desc, List<ConversationOperationResult> results, string user_data)=>{// Async result of deleting a conversation from a conversation group});
Listening for the notification of a conversation group change
Sample code:
// Set the conversation listenerTencentIMSDK.SetConvEventCallback((TIMConvEvent conv_event, List<ConvInfo> conv_list, string user_data)=>{// Process the callback logic});