問答
更新時間:2024-06-03 15:19:28
功能概述
本模組主要用於展示問答模組。
初始化及銷毀
在實例化該模組並進行使用之前,需要對SDK進行初始化配置,詳細請見參考文件。
線上檔案引入方式
// script 标签引入,根据版本号引入JS版本。
<script src="https://websdk.videocc.net/interactions-receive-sdk/0.24.0/lib/polyv-ir.umd.js"></script>
<script>
const { QuestionAnswer } = window.PolyvIRSDK;
</script>
import 方式引入(推薦)
import { QuestionAnswer } from '@polyv/interactions-receive-sdk';
const questionAnswerSdk = new QuestionAnswer();
使用流程
監聽回覆訊息
questionAnswerSdk.on(questionAnswerSdk.events.ANSWER, (msg)) => {
console.log('讲师回复消息' msg.data);
})
監聽刪除訊息
questionAnswerSdk.on(questionAnswerSdk.events.DELETE_ANSWER, (msg)) => {
console.log('删除消息' msg.data);
})
監聽sessionId改變,判斷直播狀態
questionAnswerSdk.on(questionAnswerSdk.events.UPDATE_SESSIONID, ()) => {
console.log('sessionId改变');
})
發起提問
// content 问题内容
questionAnswerSdk.sendQuestion(content);
