# Channel Management

# Channel information query

call query (opens new window) interface to query relevant channel information, such as such as channel name, existence, member name and number of members:

JCManager::shared()->mediaChannel->query("channelId");

After the query is initiated, the result of the query is reported through the onQuery (opens new window) callback:

void JCManager::onQuery(int operationId, bool result, JCMediaChannelReason reason, JCMediaChannelQueryInfo* queryInfo)
{
    //Query result
    if (result) {
        //Queried channelId
        CString channelId = queryInfo->getChannelId();
        //Queried number of members
        int number = queryInfo->getClientCount();
    }
}

# Send messages

If you want to send messages to other members in the channel, you can call the sendMessage (opens new window) method:

//The last parameter is the receiver id; if it is empty, it will be sent to all members in the channel
JCManager::shared()->mediaChannel->sendMessage(type, "message content", NULL);

Among them, type (message type) is a custom type. For types like text, image, file, etc., the message type needs to be consistent when parsing the received message.

When other members in the channel receive the message, they will receive the onMessageReceive (opens new window) callback:

void JCManager::onMessageReceive(const char* type, const char* content, const char* fromUserId)
{
    std::stringstream s;
    s << "Conf message received " << fromUserId << " type:" << type << " content:" << JCTool::Utf8ToGB2312(content);
}

# Channel member management

# Access channel members

Call the getParticipant (opens new window) method and pass in the userId of the member to get the channel member object:

JCMediaChannelParticipant* participant = JCManager::shared()->mediaChannel->getParticipant(userId);

# Access all member objects of the channel

Call the getParticipants (opens new window) method to get all the member objects of the channel:

std::list<JCMediaChannelParticipant*>* participants = JCManager::shared()->mediaChannel->getParticipants();

# Kick out members

Call the kick (opens new window) method to kick a member out of the conference:

//Access memeber objects
JCMediaChannelParticipant* participant = JCManager::shared()->mediaChannel->getParticipant(userId);
//Kick out a member
JCManager::shared()->mediaChannel->kick(participant);
最后更新时间: 2/1/2021, 3:54:49 PM