创建房间
1、调用此接口前请确保已经调用登录接口,并且登录成功;
2、房间创建后,创建者不主动释放房间,其他用户无法创建相同房间号的房间。
import { MTXLiveRoom } from "@yl/super-jssdk"
MTXLiveRoom.createRoom(optional)
| 参数 | 类型 | 必填 | 作用 |
|---|---|---|---|
| optional | Object | 是 | 必填参数 |
optional
| 参数 | 类型 | 必填 | 作用 |
|---|---|---|---|
| params | object | 是 | 登录参数,详情请参照下方 |
| onOpen | Function | 否 | 界面打开回调 |
| onClose | Function | 否 | 页面关闭回调 |
params结构说明
| 参数 | 类型 | 必填 | 作用 |
|---|---|---|---|
| roomId | number | 是 | 房间号 |
| title | string | 否 | 房间顶部标题 |
| errMsgs | object | 否 | 格式:{"100":"签名过期","101":"被踢下线",...},errCode枚举值请查看下表 |
| 参数 | 类型 | 作用 |
|---|---|---|
| resolve() | Function | 成功回调 |
| reject(err) | Function | 失败回调,err为详细错误信息,是一个json对象,例如:{"errCode":-1,"errMsg":"出错啦"} |
errorMsgs errCode枚举值
| errCode | 适用角色 | 描述 |
|---|---|---|
| 100 | 主播、观众 | 签名过期,如果errMsgs中没有包含此code,则使用默认提示:签名过期 |
| 101 | 主播、观众 | 帐号被挤下线,如果errMsgs中没有包含此code,则使用默认提示:当前用户被踢下线 |
| 102 | 主播、观众 | 腾讯sdk直接走错误回调,如果errMsgs中没有包含此code,则使用默认提示:未知错误 |
| 103 | 观众 | 主播因异常情况退出房间,此时房间未被销毁,如果errMsgs中没有包含此code,则使用默认提示:主播已离开房间 |
| 104 | 观众 | 主播点击关闭按钮退出房间,房间已被销毁,如果errMsgs中没有包含此code,则使用默认提示:直播间已被解散 |
| 105 | 观众 | 当前房间未找到正在直播的主播,如果errMsgs中没有包含此code,则使用默认提示:主播未开播 |
| 106 | 观众 | 如果errMsgs中没有包含此code,则使用默认提示:获取房间信息失败,可能此房间未创建 |
| 107 | 观众 | 如果errMsgs中没有包含此code,则使用默认提示:加入房间失败 |
| 201 | 主播 | 主播开播时创建房间失败,如果errMsgs中没有包含此code,则使用默认提示:房间创建失败 |
const params = {
"roomId": 123,
"title": "【土建工程师】张三",
};
MTXLiveRoom.createRoom(params)
.then(() => {
console.log();
})
.catch(err => {
console.log('插件调用失败:', err)
})