LiveDetailChatRoomController.ets
1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { ContentDetailDTO } from 'wdBean/Index'
import { LiveRoom } from './LiveRoom'
import { LiveRoomBaseInfo } from './LiveRoomBaseInfo'
import { LiveRoomManager } from './LiveRoomManager'
import { LiveRoomItemBean } from 'wdBean/Index';
export class LiveDetailChatRoomController {
detail?: ContentDetailDTO
///用于展示的历史消息,包含聊天室和直播间
onHistoryMessage?: (liveRoomItemBean: LiveRoomItemBean) => void
///用于管理直播间状态的消息,直播垫片,直播结束,上墙/取消上墙,置顶/取消置顶等
onLiveMessage?: (liveRoomItemBean: LiveRoomItemBean) => void
public configDetail(detail: ContentDetailDTO) {
this.detail = detail
let roomInfo = new LiveRoomBaseInfo()
roomInfo.roomID = detail.liveInfo.mlive.roomId
roomInfo.mliveID = detail.liveInfo.mlive.mliveId
roomInfo.liveID = detail.newsId + ""
this.listenConnect()
LiveRoomManager.sharedManager().connectLiveRoomWith(roomInfo)
}
listenConnect() {
LiveRoomManager.sharedManager().onConnectedRoom = (room: LiveRoom) => {
room.onJoined = (room: LiveRoom) => {
}
room.onJoinFailed = (room: LiveRoom, code: number) => {
}
room.onExited = (room: LiveRoom) => {
}
room.onHistoryMessage = (liveRoomItemBean: LiveRoomItemBean) => {
if (this.onHistoryMessage) {
this.onHistoryMessage(liveRoomItemBean)
}
}
room.onLiveMessage = (liveRoomItemBean: LiveRoomItemBean) => {
if (this.onLiveMessage) {
this.onLiveMessage(liveRoomItemBean)
}
}
room.enterRoom()
}
}
disconnectLiveRoom() {
LiveRoomManager.sharedManager().disconnect()
}
}