李勇

白板接口文档更新

# McuClient API参考说明 #
</p>
----------
##<font color=blue>McuClient 目录</font> ##
> - **创建McuClient对象**
>
> - **McuClient接口**
>
> - **McuClient回调事件**
>
> - **ErrorCode 错误码查询**
----------
##<font color=blue>使用步骤说明</font> ##
> 1. 创建McuClient对象
> 2. McuClient初始化init
> 3. 添加MessageTypes中的事件监听(接收各个模块的消息)
> 3. McuClient加入会议
> 4. 加入会议成功之后可以调用其他接口和监听事件
----------
##<font color=blue>创建McuClient对象</font> ##
只创建一次
示例代码
window.onload=function(){
//创建client,这是必须的第一步
const client=MCUClientEngine.createMcuClient();
//获取事件监听消息定义
const MessageTypes=MCUClientEngine.MessageTypes;
}
----------
## <font color=blue>McuClient接口 </font>##
### 初始化 ###
#### client.init (paramInfo,onSuccess,mcuErrorEventHandler) ####
client创建完成之后第一步需要初始化。
示例代码
var paramInfo={
"meetingNumber":123456,
"portal":"127.0.0.1:80",
"usertRole":"normal",
"userID":0,
};
//初始化
client.init(paramInfo,onSuccess,mcuErrorEventHandler);
function onSuccess(callbackData){
//初始化成功回调
/*{
"siteId": "h5test",
"passwordRequired": true,
"md5": "de399d5540b3da2fbc1eb0a770d4fd66",
"code": 0,
"msType": 1
}*/
};
function mcuErrorEventHandler(callbackData){
//整个MCUClient中Error异常监听
//返回值callbackData的结构为{"code":errorCode,"reson":""}
//errorCode的列表在文档最后面的 ErrorCode错误码查询
};
<div class="wy-table-responsive"><table border="1" class="docutils">
<colgroup>
<col width="10%">
<col width="10%">
<col width="80%">
</colgroup>
<tbody valign="mid">
<tr class="row-odd">
<td><p class="first last">参数名称</p></td>
<td><p class="first last">类型</p></td>
<td><p class="first last">该对象包含以下属性</p></td>
</tr>
<tr class="row-even">
<td rowspan="5">paramInfo</td>
<td rowspan="5"><p class="first last">对象</p></td>
</tr>
<tr class="row-odd">
<td>
<ul>
<li>meetingNumber:(必选)Number </p>课堂号</li>
</ul>
</td>
</tr>
<tr class="row-odd">
<td>
<ul>
<li>portal:(必选)String </p>IP地址</li>
</ul>
</td>
</tr>
<tr class="row-odd">
<td>
<ul>
<li>usertRole:(可选) String </p>
用户的身份,5种类型,默认是normal
;host(主持人/老师)、presenter(主讲人)、assistant(助教)、normal(普通角色/学生),record(暂时没用)</li>
</ul>
</td>
</tr>
<tr class="row-odd">
<td>
<ul>
<li>userId:(可选) String </p>
第三方用户id,默认是0
</ul>
</td>
</tr>
<tr class="row-odd">
<td><p class="first last">onSuccess</p></td>
<td><p class="first last">Function</p></td>
<td><p class="first last"><li>(必选) Function </p>初始化成功回调函数,返回值:</p>{"siteId":"h5test","passwordRequired":true,"md5":"de399d5540b3da2fbc1eb0a770d4fd66","code":0,"msType":1}
</td>
</tr>
<tr class="row-odd">
<td><p class="first last">mcuErrorEventHandler</p></td>
<td><p class="first last">Function</p></td>
<td><p class="first last"><li>(必选) Function </p>整个MCUClient中Error异常监听</p></td>
</tr>
</tbody>
</table></div>
### 加入会议 ###
#### client.joinClass (paramInfo,onSuccess) ####
client初始化成功之后,加入会议。
示例代码
var paramInfo={
"userName":"大名",//自己的名字,在列表中显示
"password":"123321",//课堂密码,如果设置了密码需要验证
};
//加入会议
client.joinClass(paramInfo,onSuccess);
function onSuccess(callbackData){
//加入会议成功回调
/*{
"siteId": "h5test",
"confId": 1292388778,
"h5Module": 0,
"nodeId": 1484789938,
"topNodeID": 101,
"userRole": "normal",
"role": 1,
"isHost": false,
"classRole": 0,
"userId": "0",
"userName": "cccccc",
"password": "222222",
"userType": 8,
"passwordRequired": true,
"md5": "b36da144521b70d89e72993cd1117b5b",
"msType": 1,
"portal": "112.126.80.182:80",
"mcuDelay": 3000,
"MCUServerIP": "123.56.73.119",
"MCUServerPort": "7001",
"maxVideoChannels": 1,
"maxAudioChannels": 1,
"maxMediaChannels": 2
}*/
};
<div class="wy-table-responsive"><table border="1" class="docutils">
<colgroup>
<col width="10%">
<col width="10%">
<col width="80%">
</colgroup>
<tbody valign="m">
<tr class="row-odd">
<td><p class="first last">参数名称</p></td>
<td><p class="first last">类型</p></td>
<td><p class="first last">该对象包含以下属性</p></td>
</tr>
<tr class="row-even">
<td rowspan="3">paramInfo</td>
<td rowspan="3"><p class="first last">对象</p></td>
</tr>
<tr class="row-odd">
<td>
<ul>
<li>userName:(必选)String </p>进入课堂的名字</li>
</ul>
</td>
</tr>
<tr class="row-odd">
<td>
<ul>
<li>password:(可选)String </p>进入课堂的密码,如果课堂不设置密码就不需要,设置了密码的情况下,进入课堂需要输入密码,根据初始化回调的参数passwordRequired来判断</li>
</ul>
</td>
</tr>
<tr class="row-odd">
<td><p class="first last">onSuccess</p></td>
<td><p class="first last">Function</p></td>
<td><p class="first last"><li>(必选) Function </p>成功回调函数</p>
</td>
</tr>
</tbody>
</table></div>
### 离开会议 ###
#### client.leaveClass() ####
离开会议
### 获取当前的状态 ###
#### client.mcuClientStatus() ####
获取当前的状态
示例代码
var callbackData=client.mcuClientStatus();
//返回一个对象
//{code:0,message:"XXXXXX"}
<div class="wy-table-responsive"><table border="1" class="docutils">
<colgroup>
<col width="10%">
<col width="10%">
<col width="80%">
</colgroup>
<tbody valign="m">
<tr class="row-odd">
<td><p class="first last">参数名称</p></td>
<td><p class="first last">类型</p></td>
<td><p class="first last">该对象包含以下属性</p></td>
</tr>
<tr class="row-even">
<td rowspan="11">callbackData</td>
<td rowspan="11"><p class="first last">对象</p></td>
</tr>
<tr class="row-odd">
<tr class="row-odd">
<td>
<ul>
<li>code:Number </p></li>
0 //SDK 未初始化</p>
1 //未加入会议</p>
2 //已经加入会议</p>
3 //已经离开会议</p>
4 //未知状态
</ul>
</td>
</tr>
<td>
<ul>
<li>message:String </p>
状态的描述,对应code,默认为空</li>
</ul>
</td>
</tr>
</tbody>
</table></div>
### 发送消息 ###
#### client.sendChatMsg(paramInfo) ####
发送聊天消息
示例代码
var paramInfo={
"message":"需要发送的内容",
"to":0
};
client.sendChatMsg(paramInfo);
<div class="wy-table-responsive"><table border="1" class="docutils">
<colgroup>
<col width="10%">
<col width="10%">
<col width="80%">
</colgroup>
<tbody valign="M">
<tr class="row-odd">
<td><p class="first last">参数名称</p></td>
<td><p class="first last">类型</p></td>
<td><p class="first last">该对象包含以下属性</p></td>
</tr>
<tr class="row-even">
<td rowspan="11">paramInfo</td>
<td rowspan="11"><p class="first last">对象</p></td>
</tr>
<tr class="row-odd">
<tr class="row-odd">
<td>
<ul>
<li>message:(必选)String </p>消息内容</li>
</ul>
</td>
</tr>
<td>
<ul>
<li>to:(可选) Number </p>
接收消息的人的ID,默认值是0(所有人都)</li>
</ul>
</td>
</tr>
</tbody>
</table></div>
### 添加白板内容 ###
#### client.sendInsertAnnotaion(paramInfo) ####
添加白板内容,可以添加任意线段、直线、矩形、圆形、文本等等内容。下面的代码中将分别演示添加(任意线段、直线、矩形、圆形、文本)内容时调用接口所要传入的参数。
示例代码
1. 添加线段(不规则);
var paramInfo={
"type": 0,
"pointGroup": [{"w":10,"h":20},{"w":11,"h":21},{"w":12,"h":22}],//有多个坐标点组成
"color": "#000000",
"thickness": 1
};
client.sendInsertAnnotaion(paramInfo);
2. 添加直线;
var paramInfo={
"type": 1,
"pointGroup": [{"w":10,"h":20},{"w":60,"h":70}],//只有两个坐标点 [起点,终点]
"color": "#000000",
"thickness": 1
};
client.sendInsertAnnotaion(paramInfo);
3. 添加矩形;
var paramInfo={
"type": 2,
"pointGroup": [{"w":10,"h":10},{"w":60,"h":60}],//矩形对角线 [对角线坐标点1,对角线坐标点2]
"color": "#000000",
"thickness": 1
};
client.sendInsertAnnotaion(paramInfo);
4. 添加圆形;
var paramInfo={
"type": 3,
"pointGroup": [{"w":50,"h":50}],//只有一个坐标点[圆的中心坐标]
"color": "#000000",
"thickness": 1,
"radius": 20
};
client.sendInsertAnnotaion(paramInfo);
5. 添加文本;
var paramInfo={
"type": 4,
"pointGroup": [{"w":10,"h":20}],//只有一个坐标点[文本的左上角坐标]
"color": "#000000",
"fontSize": 14,
"fontName": "",
"text":"文本的内容"
};
client.sendInsertAnnotaion(paramInfo);
<div class="wy-table-responsive">
<table border="1" class="docutils">
<colgroup>
<col width="10%">
<col width="10%">
<col width="80%">
</colgroup>
<tbody valign="m">
<tr class="row-odd">
<td><p class="first last">参数名称</p></td>
<td><p class="first last">类型</p></td>
<td><p class="first last">该对象包含以下属性</p></td>
</tr>
<tr class="row-even">
<td rowspan="11">paramInfo</td>
<td rowspan="11"><p class="first last">对象</p></td>
</tr>
<tr class="row-odd">
<tr class="row-odd">
<td>
<ul>
<li>type:(必选)Number</p></li>
0 (线段), 1 (直线), 2(矩形), 3(圆形), 4(文本)
</ul>
</td>
</tr>
<td>
<ul>
<li>pointGroup:(必选)array[{"w":w,"h":h}] </p>
画布上的坐标点对象集合数组,数组中坐标点对象的数量根据type的类型而定,上面有示例代码</li>
</ul>
</td>
</tr>
</tr>
<td>
<ul>
<li>text:(文本必选)String </p>
文本的内容,这个属性只有在type类型为文本的时候使用,其它类型的情况下不使用</li>
</ul>
</td>
</tr>
</tr>
<td>
<ul>
<li>radius:(绘制圆形必选)Number </p>
圆的半径(按画布宽度百分比计算),这个只在绘制圆的时候使用,其他type的时候不使用,这个值是一个相对画布宽度大小的百分比,比如在画布宽度为400,要绘制一个半径为40的圆,计算的百分比值=40/400=10%,那么radius=10</li>
</ul>
</td>
</tr>
</tr>
<td>
<ul>
<li>color:(可选)String </p>
颜色值,默认为"#000000"</li>
</ul>
</td>
</tr>
</tr>
<td>
<ul>
<li>thickness:(可选)Number </p>
线条的粗细度,除了文本之外的图像都有线条粗细,默认值为1</li>
</ul>
</td>
</tr>
</tr>
<td>
<ul>
<li>fontSize:(可选)Number </p>
文本的字体大小,默认值为14,这个属性只有在type类型为文本的时候使用,其它类型的情况下不使用</li>
</ul>
</td>
</tr>
</tr>
<td>
<ul>
<li>fontName:(可选)String </p>
文本字体,默认值为null,这个属性只有在type类型为文本的时候使用,其它类型的情况下不使用</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
## <font color=blue>McuClient 回调事件 </font>##
### 会议日志信息 事件回调 ###
示例代码
client.on(MessageTypes.CLASS_SHOW_DETAIL, function(callbackData){
//返回值
/*{
"repeatmonthweekweek": 0,
"endmode": 0,
"repeatweek": "",
"endcount": 1,
"errorCode": 0,
"cycle": 0,
"repeatmonthday": 0,
"frequency": 1,
"repeatday": 0,
"meetingName": "mcuClient",
"repeatmode": 0,
"finalenddate": "",
"meetingContent": "",
"beginTime": "2017-01-16 13:00:00",
"endTime": "2017-01-31 15:00:00",
"monthType": 0,
"category": "",
"repeatmonthweekday": 0,
"status": 1
}*/
});
### 会议有人入 事件回调 ###
示例代码
client.on(MessageTypes.CLASS_INSERT_ROSTER,function(callbackData){
//返回值
/*{
"nodeId": 1483947664,
"nodeData": {
"nodeId": 1483947664,
"name": "cccccc",
"role": 1,
"level": 0,
"audioRecords": [],
"videoRecords": [],
"status": null,
"userData": {
"qq": "",
"skype": "",
"mobile": ""
},
"userId": "0",
"handUpTime": null,
"deviceType": 3,
"mobileDirection": null
}
}*/
});
### 会议有人离开 事件回调 ###
示例代码
client.on(MessageTypes.CLASS_DELETE_ROSTER,function(callbackData){
//{"nodeId":1234}
});
### 关闭会议 事件回调 ###
示例代码
client.on(MessageTypes.CLASS_EXIT, function(callbackData){
//.....
});
### 收到聊天消息 事件回调 ###
示例代码
client.on(MessageTypes.CHAT_RECEIVE, function(callbackData){
//返回值
/*{
"fromNodeID": 1484207995,
"toNodeID": 0,
"message": "消息内容",
"fromName": "发送消息人的名字",
"fromRole": 0
}*/
});
### 视频显示 事件回调 ###
示例代码
client.on(MessageTypes.VIDEO_RECEIVE, function(callbackData){
//.....
});
### 文档 事件回调 ###
示例代码
client.on(MessageTypes.DOC_SHOW, function(callbackData){
//.....
});
### 文档笔记 事件回调 ###
示例代码
client.on(MessageTypes.DOC_ANNOTATION,function(callbackData){
//.....
});
### 删除文档 事件回调 ###
示例代码
client.on(MessageTypes.DOC_DEL,function(callbackData){
//.....
});
----------
## <font color=blue>ErrorCode 错误码查询</font> ##
<div class="wy-table-responsive">
<table border="1" class="docutils">
<colgroup>
<col width="14%">
<col width="10%">
<col width="76%">
</colgroup>
<tbody valign="M">
<tr class="row-odd">
<td><p class="first last">错误代码</p></td>
<td><p class="first last">值(code)</p></td>
<td><p class="first last">描述(reson)</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_INIT_PAEAM</td>
<td>100</td>
<td><p class="first last">初始化参数错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_INIT_NETWORK</td>
<td>101</td>
<td><p class="first last">初始化网络错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_INIT_PROTOCOL</td>
<td>102</td>
<td><p class="first last">初始化协议错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_INIT_FAILED</td>
<td>103</td>
<td><p class="first last">初始化验证失败</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_JOIN_NETWORK</td>
<td>200</td>
<td><p class="first last">加入会议网络错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_JOIN_PROTOCOL</td>
<td>201</td>
<td><p class="first last">加入会议化协议错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_JOIN_FAILED</td>
<td>202</td>
<td><p class="first last">加入会议化异常错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_JOIN_PARAM</td>
<td>203</td>
<td><p class="first last">加入会议参数错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_JOIN_FULL</td>
<td>204</td>
<td><p class="first last">人数已满</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_MD5_WRONG</td>
<td>205</td>
<td><p class="first last">MD5验证失败</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_PASSWORD_WRONG</td>
<td>206</td>
<td><p class="first last">密码错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_CLASS_JOIN_CONFILICT</td>
<td>207</td>
<td><p class="first last">已经在其它地方登陆</p></td>
</tr>
<tr class="row-even">
<td>ERR_GET_CLASS_DETAIL</td>
<td>300</td>
<td><p class="first last">获取classDetail失败</p></td>
</tr>
<tr class="row-even">
<td>ERR_GET_MEETING_PARAML</td>
<td>301</td>
<td><p class="first last">获取MeetingParam失败</p></td>
</tr>
<tr class="row-even">
<td>ERR_NETWORK</td>
<td>10000</td>
<td><p class="first last">网络错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_UNKNOWN</td>
<td>10001</td>
<td><p class="first last">未知错误</p></td>
</tr>
<tr class="row-even">
<td>ERR_SOCKET_DISCONNECT</td>
<td>20000</td>
<td><p class="first last">MCU断开连接,已经离开会议</p></td>
</tr>
</tbody>
</table>
</div>
\ No newline at end of file
... ...
不能预览此文件类型