话题互动组件

优质
小牛编辑
124浏览
2023-12-01

Mudu.Room.Topic 话题互动组件

获取话题互动设置:获取话题总页数(pageSize为10)

// 返回number
var pages = Mudu.Room.Topic.GetPage()

获取话题互动设置:是否允许观众发表话题

// 返回boolean, true为允许, false为不允许
var isAllowPublish = Mudu.Room.Topic.GetAllowPublish()

获取话题互动设置:是否允许观众回复话题

// 返回boolean, true为允许, false为不允许
var isAllowReply = Mudu.Room.Topic.GetAllowReply()

获取话题互动设置:发送内容是否需要审核

// 返回boolean, true为需要审核, false为不需要审核
var isNeedsCheck = Mudu.Room.Topic.GetNeedsCheck()

获取话题互动

// 第一个参数为页码,第二个参数为回调函数
Mudu.Room.Topic.Get(
    1,
    function (response) {
        // response格式为: {status: 'y', flag: 100, topics: [topicItem1, topicItem2, ...]}
        response = JSON.parse(response)
        console.log(response)
    }
)
  • topicItem说明
名称说明类型
idtopic唯一idnumber
visitor_idtopic所属观众的id(如果是管理员, 该字段为空字符串)string
usernametopic所属观众的昵称string
avatartopic所属观众的头像urlstring
titletopic所属观众的头衔string
messagetopic的文字内容string
imagestopic的图片url列表array
act_idtopic所属频道idnumber
checkedtopic是否已经审核通过(1为已审核通过, 0为未审核通过)number
toptopic是否被置顶(1为被置顶, 0为没有被置顶)number
is_admintopic所属观众是否是管理员(1为管理员, 0为非管理员)number
created_attopic创建时间string
updated_attopic更新时间string
repliestopic的回复列表array
  • reply 说明
名称说明类型
idreply唯一idnumber
belong_toreply所属的topic的idnumber
visitor_idreply所属观众的id(如果是管理员, 该字段为空字符串)string
usernamereply所属观众的昵称string
avatarreply所属观众的头像urlstring
titlereply所属观众的头衔string
messagereply的文字内容string
act_idreply所属频道idnumber
checkedreply是否已经审核通过(1为已审核通过, 0为未审核通过)number
is_adminreply所属观众是否是管理员(1为管理员, 0为非管理员)number
created_atreply创建时间string
updated_atreply更新时间string

发送话题互动

注: 发送话题互动前观众需要进行登录,否则发送不成功。

// 第一个参数为观众发送的内容, 其中msg为文字内容, images为图片列表, msg和images两者必须有一个不为空
// 第二个参数为发送成功或失败的回调函数
Mudu.Room.Topic.SendTopic(
    {
        msg: '欢迎来到目睹直播',
        images: [
            'https://www.xnip.cn/wp-content/uploads/2021/docimg28/36-b02pgd2yfcq.png',
            'https://www.xnip.cn/wp-content/uploads/2021/docimg28/37-kck50zjdqtb.png',
            'https://www.xnip.cn/wp-content/uploads/2021/docimg28/39-rckbn0bbpvb.png'
        ]
    },
    function (response) {
        response = JSON.parse(response)
        console.log(response)
    }
)
  • response说明
flaginfostatus
100发送成功y
101参数错误n
102管理员禁止了发起话题n
103观众被禁言n
104不允许匿名聊天n
105发送失败n
106管理员禁止了回复n

发送话题回复

注: 发送话题回复前观众需要进行登录,否则发送不成功。

// 第一个参数类型为object, 其中topicId为需要回复的话题id, msg为观众的回复内容
Mudu.Room.Topic.SendReply(
    {
        topicId: 4116,
        msg: '听说云导播台能做实时字幕,是真的吗'
    },
    function (response) {
        response = JSON.parse(response)
        console.log(response)
    }
)
  • response说明
flaginfostatus
100发送成功y
101参数错误n
102管理员禁止了发起话题n
103观众被禁言n
104不允许匿名聊天n
105发送失败n
106管理员禁止了回复n

Topic.AllowPublish事件

Topic.AllowPublish事件会在控制台话题设置->允许观众发表切换时被触发

Mudu.MsgBus.On(
    // 事件名,值为Topic.AllowPublish
    'Topic.AllowPublish', 

    // 事件处理函数,参数类型为boolean, true表示允许发表, false表示不允许发表
    function (isAllowPublish) {

    }
)

Topic.AllowReply事件

Topic.AllowReply事件会在控制台话题设置->允许观众回复切换时被触发

Mudu.MsgBus.On(
    // 事件名,值为Topic.AllowReply
    'Topic.AllowReply', 

    // 事件处理函数,参数类型为boolean, true表示允许回复, false表示不允许回复
    function (isAllowReply) {

    }
)

Topic.NeedsCheck事件

Topic.NeedsCheck事件会在控制台话题设置->发送内容需要审核切换时被触发

Mudu.MsgBus.On(
    // 事件名,值为Topic.NeedsCheck
    'Topic.NeedsCheck', 

    // 事件处理函数,参数类型为boolean, true表示需要审核, false表示不需要审核
    function (isNeedsCheck) {

    }
)

Topic.New 事件

Topic.New事件会在收到新的话题时被触发

Mudu.MsgBus.On(
    // 事件名,值为Topic.New
    'Topic.New', 

    // 事件处理函数,参数为新收到的topic
    function (topic) {
        topic = JSON.parse(topic)
        console.log(topic)
    }
)

Topic.Top 事件

Topic.Top事件会在话题被置顶或者需要置顶的时候被触发

Mudu.MsgBus.On(
    // 事件名,值为Topic.Top
    'Topic.Top', 

    // 事件处理函数,参数为被置顶或者取消置顶的topic
    function (topic) {
        topic = JSON.parse(topic)
        console.log(topic)
    }
)

Topic.Reply.New事件

Topic.Reply.New事件会在收到新的回复时被触发

Mudu.MsgBus.On(
    // 事件名,值为Topic.Reply.New
    'Topic.Reply.New', 

    // 事件处理函数,参数为新收到的reply
    function (reply) {
        reply = JSON.parse(reply)
        console.log(reply)
    }
)