|
@@ -79,6 +79,13 @@ const MessageSeatsCtrl = RongIMLib.registerMessageType('RC:Chatroom:SeatsCtrl',
|
|
// 控制是否允许发言
|
|
// 控制是否允许发言
|
|
const MessageChatBan = RongIMLib.registerMessageType('RC:Chatroom:ChatBan', true, true)
|
|
const MessageChatBan = RongIMLib.registerMessageType('RC:Chatroom:ChatBan', true, true)
|
|
|
|
|
|
|
|
+// 连麦消息
|
|
|
|
+const MessageSeatApply = RongIMLib.registerMessageType('RC:Chatroom:SeatApply', true, true)
|
|
|
|
+
|
|
|
|
+// 响应连麦消息
|
|
|
|
+const MessageSeatResponse = RongIMLib.registerMessageType('RC:Chatroom:SeatResponse', true, true)
|
|
|
|
+
|
|
|
|
+
|
|
type MessageProps = {
|
|
type MessageProps = {
|
|
messageType: 'RC:Chatroom:Welcome' | 'RC:TxtMsg' | 'RC:Chatroom:Barrage' | 'RC:Chatroom:Like' | 'RC:Chatroom:SeatsCtrl' | 'RC:Chatroom:ChatBan' | 'RC:Chatroom:SeatApply',
|
|
messageType: 'RC:Chatroom:Welcome' | 'RC:TxtMsg' | 'RC:Chatroom:Barrage' | 'RC:Chatroom:Like' | 'RC:Chatroom:SeatsCtrl' | 'RC:Chatroom:ChatBan' | 'RC:Chatroom:SeatApply',
|
|
content: any,
|
|
content: any,
|
|
@@ -94,9 +101,10 @@ const Events = RongIMLib.Events
|
|
*/
|
|
*/
|
|
const { MESSAGES, ...RestMessage } = Events
|
|
const { MESSAGES, ...RestMessage } = Events
|
|
RongIMLib.addEventListener(Events.MESSAGES, (evt: MessageEvent) => {
|
|
RongIMLib.addEventListener(Events.MESSAGES, (evt: MessageEvent) => {
|
|
- console.log(evt, '收到消息')
|
|
|
|
|
|
+ // console.log(evt, '收到消息')
|
|
const { messages } = evt
|
|
const { messages } = evt
|
|
for (const message of messages) {
|
|
for (const message of messages) {
|
|
|
|
+ // console.log(LIVE_EVENT_MESSAGE[message.messageType], message)
|
|
if (LIVE_EVENT_MESSAGE[message.messageType]) {
|
|
if (LIVE_EVENT_MESSAGE[message.messageType]) {
|
|
event.emit(LIVE_EVENT_MESSAGE[message.messageType], {...message.content, $EventMessage: message})
|
|
event.emit(LIVE_EVENT_MESSAGE[message.messageType], {...message.content, $EventMessage: message})
|
|
}
|
|
}
|
|
@@ -288,7 +296,7 @@ export const removeTrack = async (tracks: RTC.RCLocalTrack[], trackType: TrackTy
|
|
}
|
|
}
|
|
|
|
|
|
export const joinRoom = async (roomId: string, type: RTC.RCLivingType, listenEvents: RTC.IRoomEventListener | null) => {
|
|
export const joinRoom = async (roomId: string, type: RTC.RCLivingType, listenEvents: RTC.IRoomEventListener | null) => {
|
|
- await RongIMLib.joinChatRoom(roomId, {count: 0})
|
|
|
|
|
|
+ await RongIMLib.joinChatRoom(roomId, {count: -1})
|
|
const join = await runtime.rtcClient?.joinLivingRoom(roomId, type)
|
|
const join = await runtime.rtcClient?.joinLivingRoom(roomId, type)
|
|
if (join?.code != RTC.RCRTCCode.SUCCESS) throw Error('加入房间失败')
|
|
if (join?.code != RTC.RCRTCCode.SUCCESS) throw Error('加入房间失败')
|
|
join.room?.registerRoomEventListener(listenEvents)
|
|
join.room?.registerRoomEventListener(listenEvents)
|
|
@@ -304,6 +312,7 @@ export const startLive = async () => {
|
|
const room = runtime.joinedRoom
|
|
const room = runtime.joinedRoom
|
|
if (room) {
|
|
if (room) {
|
|
const microphoneAudioTrack = await getTrack('microphone')
|
|
const microphoneAudioTrack = await getTrack('microphone')
|
|
|
|
+ console.log(microphoneAudioTrack)
|
|
const cameraVideoTrack = await getTrack('camera')
|
|
const cameraVideoTrack = await getTrack('camera')
|
|
await setTrack([cameraVideoTrack], 'camera')
|
|
await setTrack([cameraVideoTrack], 'camera')
|
|
runtime.videoStatus = 'liveing'
|
|
runtime.videoStatus = 'liveing'
|
|
@@ -347,7 +356,7 @@ export const loopSyncLike = async () => {
|
|
}, 1000 * 60)
|
|
}, 1000 * 60)
|
|
}
|
|
}
|
|
|
|
|
|
-type SendMessageType = 'text' | 'image' | 'audio' | 'video' | 'file' | 'SeatsCtrl' | 'ChatBan'
|
|
|
|
|
|
+type SendMessageType = 'text' | 'image' | 'audio' | 'video' | 'file' | 'SeatsCtrl' | 'ChatBan' | 'SeatApply' | 'SeatResponse'
|
|
|
|
|
|
export const getSendMessageUser = () => {
|
|
export const getSendMessageUser = () => {
|
|
return {
|
|
return {
|
|
@@ -380,6 +389,10 @@ export const sendMessage = async (msg: any, type: SendMessageType = 'text') => {
|
|
message = new MessageSeatsCtrl(msg)
|
|
message = new MessageSeatsCtrl(msg)
|
|
} else if (type === 'ChatBan') {
|
|
} else if (type === 'ChatBan') {
|
|
message = new MessageChatBan(msg)
|
|
message = new MessageChatBan(msg)
|
|
|
|
+ } else if (type === 'SeatApply') {
|
|
|
|
+ message = new MessageSeatApply(msg)
|
|
|
|
+ } else if (type === 'SeatResponse') {
|
|
|
|
+ message = new MessageSeatResponse(msg)
|
|
}
|
|
}
|
|
if (!message) return
|
|
if (!message) return
|
|
console.log(msg)
|
|
console.log(msg)
|