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 16:32:08

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 create(liveID:) 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
ValueListenable<BattleInfo?>
Current PK information.
battleUsers
ValueListenable<List<SeatUserInfo>>
PK user list.
battleScore
ValueListenable<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
void addBattleListener(BattleListener listener);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
listener
Required
Listener.

removeBattleListener

Remove PK callback listener
void removeBattleListener(BattleListener listener);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
listener
Required
Listener.

PK Operations

requestBattle

Initiate PK request
Future<BattleRequestCompletionHandler> requestBattle({
required BattleConfig config,
required List<String> userIDList,
required int timeout,
});
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.

cancelBattleRequest

Cancel PK request
Future<CompletionHandler> cancelBattleRequest({
required String battleID,
required List<String> userIDList,
});
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
battleID
String
Required
PK ID.
userIDList
List<String>
Required
User ID list.

acceptBattle

Accept PK request
Future<CompletionHandler> acceptBattle(String battleID);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
battleID
String
Required
PK ID.

rejectBattle

Reject PK request
Future<CompletionHandler> rejectBattle(String battleID);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
battleID
String
Required
PK ID.

exitBattle

Exit PK
Future<CompletionHandler> exitBattle(String battleID);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
battleID
String
Required
PK ID.

Data Structures

BattleEndedReason

Reason for PK ending received by users in an ongoing PK
Enum Value
Value
Description
timeOver
0
PK countdown ended.
allMemberExit
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
bool
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
int
PK start marker timestamp (unit: seconds).
endTime
int
PK end marker timestamp (unit: seconds).

BattleState

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

BattleRequestCompletionHandler

PK request completion handler
Completion handler for PK requests in Dart, containing the result of the PK request.
Properties
Property
Type
Description
battleInfo
PK information returned on success.
resultMap
Map<String, int>?
Response result mapping for PK request.

Usage Example

// Create store instance
final store = BattleStore.create('live_room_123');

// Define listeners
late final VoidCallback battleInfoListener = _onBattleInfoChanged;
late final VoidCallback battleUsersListener = _onBattleUsersChanged;

void _onBattleInfoChanged() {
final battleInfo = store.battleState.currentBattleInfo.value;
if (battleInfo != null) {
print('Current PK ID: ${battleInfo.battleID}');
}
}

void _onBattleUsersChanged() {
print('PK user count: ${store.battleState.battleUsers.value.length}');
}

// Subscribe to state changes
store.battleState.currentBattleInfo.addListener(battleInfoListener);
store.battleState.battleUsers.addListener(battleUsersListener);

// Add PK event listener
final battleListener = BattleListener(
onBattleStarted: (battleInfo, inviter, invitees) {
print('PK started, initiator: ${inviter.userName}');
},
onBattleEnded: (battleInfo, reason) {
print('PK ended, reason: $reason');
},
);
store.addBattleListener(battleListener);

// Initiate PK request
final config = BattleConfig(duration: 300, needResponse: true);
final result = await store.requestBattle(
config: config,
userIDList: ['user_456'],
timeout: 30,
);
if (result.code == 0) {
print('PK request successful: ${result.battleInfo?.battleID}');
} else {
print('PK request failed: ${result.message}');
}

// Unsubscribe when done
store.battleState.currentBattleInfo.removeListener(battleInfoListener);
store.battleState.battleUsers.removeListener(battleUsersListener);
store.removeBattleListener(battleListener);


ヘルプとサポート

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

フィードバック