tencent cloud

Tencent Real-Time Communication

お知らせ・リリースノート
製品アップデート情報
Tencent Cloudオーディオビデオ端末SDKの再生アップグレードおよび承認チェック追加に関するお知らせ
TRTCアプリケーションのサブスクリプションパッケージサービスのリリースに関する説明について
製品の説明
製品概要
基礎概念
製品の機能
製品の強み
ユースケース
性能データ
購入ガイド
Billing Overview
無料時間の説明
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
課金に関するよくあるご質問
Refund Instructions
初心者ガイド
Demo体験
Call
コンポーネントの説明(TUICallKit)
Activate the Service
Run Demo
クイック導入
オフライン通知
Conversational Chat
クラウドレコーディング(TUICallKit)
AI Noise Reduction
インターフェースのカスタマイズ
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
公開ログ
よくある質問
ライブ配信
Billing of Video Live Component
Overview
Activating the Service (TUILiveKit)
Demo のクイックスタート
No UI Integration
UI Customization
Live Broadcast Monitoring
Video Live Streaming
Voice Chat Room
Advanced Features
Client APIs
Server APIs
Error Codes
Release Notes
FAQs
RTC Engine
Activate Service
SDKのダウンロード
APIコードサンプル
Usage Guidelines
クライアント側 API
高度な機能
RTC RESTFUL API
History
Introduction
API Category
Room Management APIs
Stream mixing and relay APIs
On-cloud recording APIs
Data Monitoring APIs
Pull stream Relay Related interface
Web Record APIs
AI Service APIs
Cloud Slicing APIs
Cloud Moderation APIs
Making API Requests
Call Quality Monitoring APIs
Usage Statistics APIs
Data Types
Appendix
Error Codes
コンソールガイド
アプリケーション管理
使用統計
監視ダッシュボード
開発支援
Solution
Real-Time Chorus
よくあるご質問
課金関連問題
機能関連
UserSig関連
ファイアウォールの制限の対応関連
インストールパッケージの圧縮に関するご質問
AndriodおよびiOS関連
Web端末関連
Flutter関連
Electron関連
TRTCCalling Web関連
オーディオビデオ品質関連
その他のご質問
旧バージョンのドキュメント
TUIRoom(Web)の統合
TUIRoom (Android)の統合
TUIRoom (iOS)の統合
TUIRoom (Flutter)の統合
TUIRoom (Electron)の統合
TUIRoom APIのクエリー
クラウドレコーディングと再生の実現(旧)
Protocols and Policies
セキュリティコンプライアンス認証
セキュリティホワイトペーパー
情報セキュリティの説明
Service Level Agreement
Apple Privacy Policy: PrivacyInfo.xcprivacy
TRTC ポリシー
プライバシーポリシー
データ処理とセキュリティ契約
用語集

BattleStore

PDF
フォーカスモード
フォントサイズ
最終更新日: 2026-03-05 17:36:39

Introduction

PK feature enables real-time interactive battles between hosts. BattleStore provides a comprehensive set of APIs to manage the entire PK lifecycle.
Important:
Always use the factory method BattleStore.create with a valid live room ID to create a BattleStore instance. Do not attempt to initialize directly.
Note:
PK state updates are delivered through the battleState publisher. Subscribe to it to receive real-time updates about PK information, participating users, and scores.
Warning:
If a PK request does not receive a response within the specified timeout, a timeout event will be triggered. Always handle timeout scenarios in the UI.

Features

PK Request Management:Hosts can initiate PK requests, and invitees can accept or reject
State Management:Real-time tracking of PK information, participating users, and scores
Event-Driven Architecture:Provides complete PK event callbacks
Timeout Handling:Built-in timeout mechanism for PK requests

Subscribable Data

BattleState fields are described below:
Property
Type
Description
currentBattleInfo
StateFlow<BattleInfo?>
Current PK information.
battleUsers
StateFlow<List<SeatUserInfo>>
PK user list.
battleScore
StateFlow<Map<String, Int>>
PK score mapping.

API List

Function
Description
Create BattleStore instance.
PK event callbacks.
PK event callbacks.
Initiate PK request.
Cancel PK request.
Accept PK request.
Reject PK request.
Exit PK.

Creating Instance

BattleStore.create

Create BattleStore instance

Observing State and Events

addBattleListener

Add PK callback listener
abstract fun addBattleListener(listener: BattleListener?)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
listener
Required
Listener.

removeBattleListener

Remove PK callback listener
abstract fun removeBattleListener(listener: BattleListener?)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
listener
Required
Listener.

PK Operations

requestBattle

Initiate PK request
abstract fun requestBattle(
config: BattleConfig,
userIDList: List<String>,
timeout: Int,
completion: BattleRequestCallback?
)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
config
Required
PK configuration.
userIDList
List<String>
Required
List of user IDs to join PK.
timeout
Int
Required
Request timeout duration.
completion
Required
Callback for successful request initiation.

cancelBattleRequest

Cancel PK request
abstract fun cancelBattleRequest(
battleID: String?,
userIDList: List<String>,
completion: CompletionHandler?
)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
battleID
String?
Required
PK ID.
userIDList
List<String>
Required
User ID list.
completion
Required
Callback for successful cancellation.

acceptBattle

Accept PK request
abstract fun acceptBattle(
battleID: String?,
completion: CompletionHandler?
)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
battleID
String?
Required
PK ID.
completion
Required
Callback for successful acceptance.

rejectBattle

Reject PK request
abstract fun rejectBattle(
battleID: String?,
completion: CompletionHandler?
)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
battleID
String?
Required
PK ID.
completion
Required
Callback for successful rejection.

exitBattle

Exit PK
abstract fun exitBattle(
battleID: String?,
completion: CompletionHandler?
)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
battleID
String?
Required
PK ID.
completion
Required
Callback for successful exit.

Data Structures

BattleEndedReason

Reason for PK ending received by users in an ongoing PK
Enum Value
Value
Description
TIME_OVER
0
PK countdown ended.
ALL_MEMBER_EXIT
1
All PK members exited.

BattleListener

PK-related callback events received
Methods
Method
Description
onBattleStarted
This callback is triggered when PK officially starts, notifying all participants that PK has begun.
onBattleEnded
This callback is triggered when PK ends.
onUserJoinBattle
This callback is triggered when a user joins PK.
onUserExitBattle
This callback is triggered when a user exits PK.
onBattleRequestReceived
This callback is triggered when a PK request is received.
onBattleRequestCancelled
This callback is triggered when a PK request is cancelled.
onBattleRequestTimeout
This callback is triggered when a PK request times out.
onBattleRequestAccept
This callback is triggered when a PK request is accepted.
onBattleRequestReject
This callback is triggered when a PK request is rejected.

BattleConfig

PK configuration information set when sending a PK request
Property
Type
Description
duration
Int
PK duration (unit: seconds).
needResponse
Boolean
Whether the invitee needs to reply with accept/reject.
extensionInfo
String
Extension information.

BattleInfo

PK information
Property
Type
Description
battleID
String
PK ID.
config
PK configuration information set when sending a PK request.
startTime
Long
PK start marker timestamp (unit: seconds).
endTime
Long
PK end marker timestamp (unit: seconds).

BattleState

PK-related state data provided by BattleStore
Property
Type
Description
currentBattleInfo
StateFlow<BattleInfo?>
Current PK information.
battleUsers
StateFlow<List<SeatUserInfo>>
PK user list.
battleScore
StateFlow<Map<String, Int>>
PK score mapping.

BattleRequestCallback

PK request callback
Callback interface for PK requests, used to handle success or failure results of PK requests.
Methods
onSuccess: Success callback.
fun onSuccess(battleInfo: BattleInfo, resultMap: Map<String, Int>)
Parameter
Type
Description
battleInfo
PK information, containing detailed configuration and status of the PK.
resultMap
Map<String, Int>
Response result callback for PK request.
onError: Failure callback.
fun onError(code: Int, desc: String)
Parameter
Type
Description
code
Int
Error code.
desc
String
Error description.

Usage Example

// Create store instance
val store = BattleStore.create("live_room_123")

// Subscribe to state changes
lifecycleScope.launch {
store.battleState.currentBattleInfo.collect { battleInfo ->
battleInfo?.let {
println("Current PK ID: ${it.battleID}")
}
}
}

// Add PK event listener
store.addBattleListener(object : BattleListener() {
override fun onBattleStarted(battleInfo: BattleInfo, inviter: SeatUserInfo, invitees: List<SeatUserInfo>) {
println("PK started, initiator: ${inviter.userName}")
}
override fun onBattleEnded(battleInfo: BattleInfo, reason: BattleEndedReason?) {
println("PK ended, reason: $reason")
}
})

// Initiate PK request
val config = BattleConfig(duration = 300, needResponse = true)
store.requestBattle(config, listOf("user_456"), 30, object : BattleRequestCallback {
override fun onSuccess(battleInfo: BattleInfo, resultMap: Map<String, Int>) {
println("PK request successful: ${battleInfo.battleID}")
}
override fun onError(code: Int, desc: String) {
println("PK request failed: $desc")
}
})


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック