Setting the user type
PlanetKit provides a feature to set a user type when joining a group call, enabling your application to distinguish between different categories of users.
You can define custom user types (for example, regular users and bots) and tailor your application's behavior or UI based on the user type. Additionally, LINE Planet reserves certain user type values for built-in agent roles.
Supported call type | Minimum SDK version |
---|---|
Group call (conference) | PlanetKit 6.1 |
User types
User types are classified as follows:
- Custom user types
- User types defined and managed by your application
- Value range: 1 to 9999
- PlanetKit user types
- User types used internally by LINE Planet to represent agent roles, defined in
PlanetKitUserType
- Value range: 0, 10000 to 99999
- For more information, see the Agent call documentation.
- User types used internally by LINE Planet to represent agent roles, defined in
Sample code
The following sample code shows how to use the feature to set the user type.
Define and set the user type
Define the application user types according to your requirements. When joining a group call, set a user type with ConferenceParam::SetCustomUserType()
.
constexpr unsigned int CustomUserTypeRegularUser = 1;
constexpr unsigned int CustomUserTypeBot = 2;
class YourConference {
public :
void JoinConference(PlanetKit::UserIdPtr pMyId, PlanetKit::MicPtr) {
auto pConferenceParam = PlanetKit::ConferenceParam::CreateWithAccessToken(pMyId, L"YourRoomId", L"YourRoomServiceId", L"YourAccessToken");
// Set other parameters as needed.
...
bool bResult = pConferenceParam->SetCustomUserType(CustomUserTypeRegularUser);
auto pMic = PlanetKit::PlanetKitManager::GetInstance()->GetAudioManager()->GetCurrentMic();
auto sJoinResult = PlanetKit::PlanetKitManager::GetInstance()->JoinConference(pConferenceParam, pMic, m_pConference);
}
private :
PlanetKit::PlanetKitConferencePtr m_pConference;
};
Implement actions for each user type
Implement actions to be processed according to each user type. You can use the APIs of UserTypeContainer
to check for the user type.
class YourConferenceEvent : public PlanetKit::IConferenceEvent {
public :
void OnPeerListUpdate(PlanetKit::PlanetKitConferencePtr pPlanetKitConference, PlanetKit::ConferencePeerUpdateParamPtr pParam) override {
auto arrayAddedPeer = pParam->GetAddedPeer();
for(int idx = 0; idx < arrayAddedPeer.Size(); ++idx) {
auto pPeer = arrayAddedPeer.At(idx);
auto pUserTypeContainer = pPeer->GetUserType();
if(pUserTypeContainer->IsPlanetKitUserType()) {
// Predefined user types in PlanetKit.
auto ePlanetKitPredefined = pUserTypeContainer->GetPlanetKitUserType().Value();
}
else {
// Custom user type that you set.
switch(pUserTypeContainer->GetCustomUserType().Value()) {
case CustomUserTypeRegularUser :
// CustomUserTypeRegularUser
break;
case CustomUserTypeBot :
// CustomUserTypeBot
break;
}
}
}
}
};