Skip to content

Commit 149132c

Browse files
committed
add FeedStatusController.ts
1 parent f538598 commit 149132c

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

cocos/misc/FeedStatusController.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
3+
4+
https://www.cocos.com/
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10+
of the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.
23+
*/
24+
25+
/**
26+
* @en Direct Play enters and exits the control component: controls the following two APIs in Direct Play
27+
1. Monitor feed streams for entering/exiting mini game events,
28+
2. Cancel monitoring of feed streams entering/exiting mini game events.
29+
Can only run in a mini game environment
30+
*
31+
* @zh 直玩游戏进入退出管控组件: 管控直玩中的如下两个API.
32+
1.监听 Feed 流进入/退出小游戏事件,
33+
2.取消监听 Feed 流进入/退出小游戏事件。
34+
只能在小游戏环境运行
35+
*/
36+
import { _decorator } from '../core';
37+
import { Component } from '../scene-graph/component';
38+
const { ccclass } = _decorator;
39+
40+
declare const minigame: any;
41+
@ccclass('FeedStatusController')
42+
export class FeedStatusController extends Component {
43+
protected start (): void {
44+
if (minigame && minigame.onFeedStatusChange) {
45+
minigame.onFeedStatusChange(this.feedStatusChangeCallBack);
46+
}
47+
}
48+
49+
protected feedStatusChangeCallBack (type: any): void {
50+
51+
}
52+
53+
protected onDestroy (): void {
54+
if (minigame && minigame.offFeedStatusChange) {
55+
minigame.offFeedStatusChange(this.feedStatusChangeCallBack);
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)