本文にスキップする
Version: 6.1

ユーザータイプの設定

PlanetKitは、グループ通話に参加する際にアプリケーションで異なるカテゴリのユーザーを区別できるよう、ユーザータイプを設定する機能を提供します。

この機能を使用すると、カスタムユーザータイプ(例:一般ユーザーとボット)を定義し、ユーザータイプに応じてアプリケーションの動作やUIを変えることができます。なお、LINE Planetは一部のユーザータイプの値をビルトインエージェントの役割のために予約しています。

通話タイプSDKの最低バージョン
グループ通話(カンファレンス)PlanetKit 6.1

ユーザータイプ

ユーザータイプは大きく次のように分類されます。

  • カスタムユーザータイプ
    • アプリケーションで定義し、管理するユーザータイプです。
    • 値の範囲:1~9999
  • PlanetKitユーザータイプ
    • LINE Planetで内部的にエージェントの役割として使用するユーザータイプで、PlanetKitUserTypeに定義されています。
    • 値の範囲:0、10000~99999
    • 詳しくは、エージェント通話を参照してください。

サンプルコード

以下は、ユーザータイプの設定機能を使用するサンプルコードです。

ユーザータイプの定義および設定

要件に合わせてアプリケーションのユーザータイプを定義し、グループ通話に参加する際に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;
};

各ユーザータイプに適用するロジック実装

各ユーザータイプに合わせて処理するロジックを実装します。UserTypeContainerAPIを使用してユーザータイプを確認できます。

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;
}
}
}
}
};

関連API