1.课堂初始化接口增加是否延迟接收消息的字段
2.sass接口中增加延迟消息的时间长度的字段,单位是秒 3.APE默认所有模块都支持延迟消息 3.mcu增加延迟消息判断
正在显示
9 个修改的文件
包含
218 行增加
和
201 行删除
此 diff 太大无法显示。
| @@ -300,6 +300,9 @@ export default class MessageEntrance extends Emiter { | @@ -300,6 +300,9 @@ export default class MessageEntrance extends Emiter { | ||
| 300 | GlobalConfig.userId = _param.userId || "0"; | 300 | GlobalConfig.userId = _param.userId || "0"; |
| 301 | GlobalConfig.userName = _param.userName || ""; | 301 | GlobalConfig.userName = _param.userName || ""; |
| 302 | 302 | ||
| 303 | + //客户端决定是否延迟接收消息 | ||
| 304 | + GlobalConfig.messageDelay = _param.messageDelay || false; | ||
| 305 | + | ||
| 303 | //最长允许录制的时间 | 306 | //最长允许录制的时间 |
| 304 | if(_param.allowRecordMaxTime){ | 307 | if(_param.allowRecordMaxTime){ |
| 305 | GlobalConfig.allowRecordMaxTime=parseInt(_param.allowRecordMaxTime); | 308 | GlobalConfig.allowRecordMaxTime=parseInt(_param.allowRecordMaxTime); |
| @@ -412,7 +415,7 @@ export default class MessageEntrance extends Emiter { | @@ -412,7 +415,7 @@ export default class MessageEntrance extends Emiter { | ||
| 412 | // console.log(_data); | 415 | // console.log(_data); |
| 413 | //包含整个课堂最全的信息,储存数据 | 416 | //包含整个课堂最全的信息,储存数据 |
| 414 | if (_data) { | 417 | if (_data) { |
| 415 | - GlobalConfig.mcuDelay = _data.mcuDelay || 60;//mcu消息延迟,用于文档模块 | 418 | + GlobalConfig.mcuDelay = _data.h5Delay || 0;//mcu消息延迟的时间间隔,单位(秒),结合客户端传的messageDelay的值使用 |
| 416 | GlobalConfig.className = _data.meetingName || ""; | 419 | GlobalConfig.className = _data.meetingName || ""; |
| 417 | GlobalConfig.classBeginTime = _data.beginTime || ""; | 420 | GlobalConfig.classBeginTime = _data.beginTime || ""; |
| 418 | GlobalConfig.classEndTime = _data.endTime || ""; | 421 | GlobalConfig.classEndTime = _data.endTime || ""; |
| @@ -242,8 +242,10 @@ GlobalConfig.statusCode_4={"code":4,message:"未知状态"}; | @@ -242,8 +242,10 @@ GlobalConfig.statusCode_4={"code":4,message:"未知状态"}; | ||
| 242 | 242 | ||
| 243 | GlobalConfig.md5=""; | 243 | GlobalConfig.md5=""; |
| 244 | GlobalConfig.msType=1;//目前固定用这个 | 244 | GlobalConfig.msType=1;//目前固定用这个 |
| 245 | -GlobalConfig.mcuDelay=60;//默认的延迟时间 flash中使用的是3000毫秒 | ||
| 246 | -GlobalConfig.docDelay=1600;//文档模块加入成功之后延迟发送送成功的消息给主模块 | 245 | +GlobalConfig.messageDelay=false;//是否启用消息延迟 |
| 246 | +GlobalConfig.mcuDelay=0;//默认的延迟时间(单位-秒) | ||
| 247 | + | ||
| 248 | +GlobalConfig.docDelay=1600;//文档模块加入成功之后延迟发送送成功的消息给主模块(sdk内部使用) | ||
| 247 | GlobalConfig.portal="112.126.80.182:80";//Sass IP | 249 | GlobalConfig.portal="112.126.80.182:80";//Sass IP |
| 248 | 250 | ||
| 249 | //GlobalConfig.ip="112.126.80.182"; | 251 | //GlobalConfig.ip="112.126.80.182"; |
| @@ -201,7 +201,7 @@ class Sass extends Emiter { | @@ -201,7 +201,7 @@ class Sass extends Emiter { | ||
| 201 | 201 | ||
| 202 | // 获取课堂基本详情------------------------------------------------------------------------------------ | 202 | // 获取课堂基本详情------------------------------------------------------------------------------------ |
| 203 | getClassDetail() { | 203 | getClassDetail() { |
| 204 | - let url = `http://${confInfo.portal}/3m/meeting/getClassH5.do?classNumber=${confInfo.classId}`; | 204 | + let url = `http://${GlobalConfig.portal}/3m/meeting/getClassH5.do?classNumber=${GlobalConfig.classId}`; |
| 205 | loger.log('获取Class详情.', url); | 205 | loger.log('获取Class详情.', url); |
| 206 | fetch(url, { | 206 | fetch(url, { |
| 207 | timeout: 5000 | 207 | timeout: 5000 |
| @@ -300,7 +300,7 @@ class Sass extends Emiter { | @@ -300,7 +300,7 @@ class Sass extends Emiter { | ||
| 300 | } | 300 | } |
| 301 | var timestamp = new Date().getTime(); | 301 | var timestamp = new Date().getTime(); |
| 302 | var authId = MD5(_param.docId + "" + _param.classId + "" + timestamp);// docId+classId+timestamp的字符串,转成MD5 | 302 | var authId = MD5(_param.docId + "" + _param.classId + "" + timestamp);// docId+classId+timestamp的字符串,转成MD5 |
| 303 | - let url = `http://${confInfo.portal}/3m/api/document/deleteRelation.do?docId=${_param.docId}&classId=${confInfo.classId}×tamp=${timestamp}&authId=${authId}`; | 303 | + let url = `http://${GlobalConfig.portal}/3m/api/document/deleteRelation.do?docId=${_param.docId}&classId=${GlobalConfig.classId}×tamp=${timestamp}&authId=${authId}`; |
| 304 | loger.log('sassDeleteDocument', url); | 304 | loger.log('sassDeleteDocument', url); |
| 305 | 305 | ||
| 306 | fetch(url, { | 306 | fetch(url, { |
| @@ -350,16 +350,16 @@ class Sass extends Emiter { | @@ -350,16 +350,16 @@ class Sass extends Emiter { | ||
| 350 | } | 350 | } |
| 351 | //{"classStatusInfo":classStatusInfo} | 351 | //{"classStatusInfo":classStatusInfo} |
| 352 | var timestamp = new Date().getTime(); | 352 | var timestamp = new Date().getTime(); |
| 353 | - var authId = MD5(confInfo.classId + "" + timestamp);// (classId+timestamp)的字符串,转成MD5 | 353 | + var authId = MD5(GlobalConfig.classId + "" + timestamp);// (classId+timestamp)的字符串,转成MD5 |
| 354 | let classStatusInfo = JSON.stringify(_param.classStatusInfo); | 354 | let classStatusInfo = JSON.stringify(_param.classStatusInfo); |
| 355 | - let url = `http://${confInfo.portal}/3m/api/meeting/saveInfo.do`; | 355 | + let url = `http://${GlobalConfig.portal}/3m/api/meeting/saveInfo.do`; |
| 356 | loger.log('saveClassStatusInfo', url); | 356 | loger.log('saveClassStatusInfo', url); |
| 357 | fetch(url, { | 357 | fetch(url, { |
| 358 | method: 'POST', | 358 | method: 'POST', |
| 359 | headers: { | 359 | headers: { |
| 360 | "Content-Type": "application/x-www-form-urlencoded" | 360 | "Content-Type": "application/x-www-form-urlencoded" |
| 361 | }, | 361 | }, |
| 362 | - body: `classId=${confInfo.classId}&info=${classStatusInfo}×tamp=${timestamp}&authId=${authId}`, | 362 | + body: `classId=${GlobalConfig.classId}&info=${classStatusInfo}×tamp=${timestamp}&authId=${authId}`, |
| 363 | timeout: 5000 | 363 | timeout: 5000 |
| 364 | }) | 364 | }) |
| 365 | .then(ret => { | 365 | .then(ret => { |
| @@ -416,7 +416,7 @@ class Sass extends Emiter { | @@ -416,7 +416,7 @@ class Sass extends Emiter { | ||
| 416 | 416 | ||
| 417 | let timestamp = new Date().getTime(); | 417 | let timestamp = new Date().getTime(); |
| 418 | let authId = MD5(key + siteID + meetingID + timestamp); | 418 | let authId = MD5(key + siteID + meetingID + timestamp); |
| 419 | - let url = `http://${confInfo.portal}/3m/recordingMeeting/insertRecordingMeeting.do?siteID=${siteID}&meetingID=${meetingID}&userID=${userID}&userName=${userName}&meetingName=${meetingName}&startTime=${startTime}&endTime=${endTime}&playUrl=${playUrl}&streamName=${streamName}&downloadUrl=${downloadUrl}&configFile=${confRecordFileName}×tamp=${timestamp}&recordTimestamp=${recordTimestamp}&authId=${authId}`; | 419 | + let url = `http://${GlobalConfig.portal}/3m/recordingMeeting/insertRecordingMeeting.do?siteID=${siteID}&meetingID=${meetingID}&userID=${userID}&userName=${userName}&meetingName=${meetingName}&startTime=${startTime}&endTime=${endTime}&playUrl=${playUrl}&streamName=${streamName}&downloadUrl=${downloadUrl}&configFile=${confRecordFileName}×tamp=${timestamp}&recordTimestamp=${recordTimestamp}&authId=${authId}`; |
| 420 | loger.log('saveClassRecordContrlInfo', url); | 420 | loger.log('saveClassRecordContrlInfo', url); |
| 421 | 421 | ||
| 422 | fetch(url, { | 422 | fetch(url, { |
| @@ -27,6 +27,8 @@ let speedTestPort = ':5555';//测速端口统一 | @@ -27,6 +27,8 @@ let speedTestPort = ':5555';//测速端口统一 | ||
| 27 | 27 | ||
| 28 | let checkMcuIpGroup =[];//储存MCU需要查询的ip数组 | 28 | let checkMcuIpGroup =[];//储存MCU需要查询的ip数组 |
| 29 | let checkMsIpGroup =[];//储存MCU需要查询的ip数组 | 29 | let checkMsIpGroup =[];//储存MCU需要查询的ip数组 |
| 30 | +const timeOutDelay=1000;//选点超时 | ||
| 31 | + | ||
| 30 | class ServerCheck extends Emiter { | 32 | class ServerCheck extends Emiter { |
| 31 | constructor() { | 33 | constructor() { |
| 32 | super(); | 34 | super(); |
| @@ -52,7 +54,7 @@ class ServerCheck extends Emiter { | @@ -52,7 +54,7 @@ class ServerCheck extends Emiter { | ||
| 52 | loger.log('获取IP信息 ', userIp, location); | 54 | loger.log('获取IP信息 ', userIp, location); |
| 53 | 55 | ||
| 54 | fetchJsonp(location, { | 56 | fetchJsonp(location, { |
| 55 | - timeout: 3000, | 57 | + timeout: timeOutDelay, |
| 56 | }).then(function (response) { | 58 | }).then(function (response) { |
| 57 | return response.json() | 59 | return response.json() |
| 58 | }).then(function (json) { | 60 | }).then(function (json) { |
| @@ -168,7 +170,7 @@ class ServerCheck extends Emiter { | @@ -168,7 +170,7 @@ class ServerCheck extends Emiter { | ||
| 168 | //loger.log('getBestMcuServer done -> ', fatest_ip_response); | 170 | //loger.log('getBestMcuServer done -> ', fatest_ip_response); |
| 169 | this._getBestMcuServerCallbackHandler(fatest_ip_response) | 171 | this._getBestMcuServerCallbackHandler(fatest_ip_response) |
| 170 | } | 172 | } |
| 171 | - }.bind(this), 3000); | 173 | + }.bind(this), timeOutDelay); |
| 172 | } | 174 | } |
| 173 | 175 | ||
| 174 | //获取最快的MS服务器地址,参数是一个ip数组 | 176 | //获取最快的MS服务器地址,参数是一个ip数组 |
| @@ -186,7 +188,7 @@ class ServerCheck extends Emiter { | @@ -186,7 +188,7 @@ class ServerCheck extends Emiter { | ||
| 186 | //loger.log('getBestMsServer done -> ', fatest_ip_response); | 188 | //loger.log('getBestMsServer done -> ', fatest_ip_response); |
| 187 | this._getBestMsServerCallbackHandler(fatest_ip_response); | 189 | this._getBestMsServerCallbackHandler(fatest_ip_response); |
| 188 | } | 190 | } |
| 189 | - }.bind(this), 3000); | 191 | + }.bind(this), timeOutDelay); |
| 190 | } | 192 | } |
| 191 | 193 | ||
| 192 | _getBestMcuServerCallbackHandler(_data) { | 194 | _getBestMcuServerCallbackHandler(_data) { |
| @@ -40,7 +40,7 @@ export default class Ape extends Emiter { | @@ -40,7 +40,7 @@ export default class Ape extends Emiter { | ||
| 40 | this._adapter_pdu = new pdu['RCAdapterPdu']; | 40 | this._adapter_pdu = new pdu['RCAdapterPdu']; |
| 41 | this._classInfo = null; | 41 | this._classInfo = null; |
| 42 | this._rCArrayBufferUtil = ArrayBufferUtil; | 42 | this._rCArrayBufferUtil = ArrayBufferUtil; |
| 43 | - this._apeDelayed = false; | 43 | + this._apeDelayed = true; |
| 44 | this._apeDelayedMsgs = []; | 44 | this._apeDelayedMsgs = []; |
| 45 | this._apeDelayedTimer = 0; | 45 | this._apeDelayedTimer = 0; |
| 46 | 46 | ||
| @@ -75,15 +75,17 @@ export default class Ape extends Emiter { | @@ -75,15 +75,17 @@ export default class Ape extends Emiter { | ||
| 75 | // 消息处理 | 75 | // 消息处理 |
| 76 | _pduMessageHandler(regBuffer,_seekTime) { | 76 | _pduMessageHandler(regBuffer,_seekTime) { |
| 77 | let seekTime=_seekTime||0;//这个只有在录制回放的时候才有 | 77 | let seekTime=_seekTime||0;//这个只有在录制回放的时候才有 |
| 78 | - //loger.log("RCPDU_REG_ADAPTER============seekTime",seekTime); | ||
| 79 | - if (this._apeDelayed) { | ||
| 80 | - // this._apeDelayedMsgs.push(regBuffer); | ||
| 81 | - // this._apeDelayedStart(); | 78 | + /* loger.warn('APE->收到消息处理->',GlobalConfig.mcuDelay,GlobalConfig.messageDelay); |
| 79 | + //延迟处理消息(3个条件--->ape允许延迟&&客户端设置需要延迟&&Sass设置的延迟时间大于0) | ||
| 80 | + if (this._apeDelayed&&GlobalConfig.messageDelay&&GlobalConfig.mcuDelay>0) { | ||
| 81 | + loger.warn('延迟处理消息->',GlobalConfig.mcuDelay); | ||
| 82 | setTimeout(() => { | 82 | setTimeout(() => { |
| 83 | this._pduRegAdapterHandler(regBuffer,seekTime); | 83 | this._pduRegAdapterHandler(regBuffer,seekTime); |
| 84 | - }, GlobalConfig.mcuDelay || 2000); | 84 | + }, GlobalConfig.mcuDelay*1000);//mcuDelay单位是秒,这里需要换算为毫秒 |
| 85 | return; | 85 | return; |
| 86 | } | 86 | } |
| 87 | +*/ | ||
| 88 | + //不延迟,立即处理 | ||
| 87 | this._pduRegAdapterHandler(regBuffer,seekTime); | 89 | this._pduRegAdapterHandler(regBuffer,seekTime); |
| 88 | } | 90 | } |
| 89 | 91 | ||
| @@ -164,7 +166,7 @@ export default class Ape extends Emiter { | @@ -164,7 +166,7 @@ export default class Ape extends Emiter { | ||
| 164 | let tableUpdateItems = tableUpdateData.items; | 166 | let tableUpdateItems = tableUpdateData.items; |
| 165 | let tableUpdateItemsLen = tableUpdateItems.length; | 167 | let tableUpdateItemsLen = tableUpdateItems.length; |
| 166 | //loger.log("RCRegistryTableUpdateItemPdu " + tableUpdateItemsLen); | 168 | //loger.log("RCRegistryTableUpdateItemPdu " + tableUpdateItemsLen); |
| 167 | - loger.log(tableUpdateData); | 169 | + //loger.log(tableUpdateData); |
| 168 | 170 | ||
| 169 | for (let i = 0; i < tableUpdateItemsLen; ++i) { | 171 | for (let i = 0; i < tableUpdateItemsLen; ++i) { |
| 170 | let tableItem = tableUpdateItems[i]; | 172 | let tableItem = tableUpdateItems[i]; |
| @@ -34,8 +34,6 @@ class DocApe extends Ape { | @@ -34,8 +34,6 @@ class DocApe extends Ape { | ||
| 34 | this.docList = {};//记录文档的数组this.docList[itemIdx]=itemIdx的数据 | 34 | this.docList = {};//记录文档的数组this.docList[itemIdx]=itemIdx的数据 |
| 35 | //this.activeDocItemIdx =0;//当前激活的文档itemIdx | 35 | //this.activeDocItemIdx =0;//当前激活的文档itemIdx |
| 36 | //this.activeDocCurPage=1;//当前激活的文档的当前页 | 36 | //this.activeDocCurPage=1;//当前激活的文档的当前页 |
| 37 | - // 延迟 | ||
| 38 | - this._apeDelayed = false; | ||
| 39 | 37 | ||
| 40 | // Ape Models | 38 | // Ape Models |
| 41 | this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); | 39 | this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); |
| @@ -43,8 +43,6 @@ class WhiteBoardApe extends Ape { | @@ -43,8 +43,6 @@ class WhiteBoardApe extends Ape { | ||
| 43 | this.annoInfos = {};//储存所有的标注数据 | 43 | this.annoInfos = {};//储存所有的标注数据 |
| 44 | this.insertHistory = [];//添加的白板记录,用于撤回操作 | 44 | this.insertHistory = [];//添加的白板记录,用于撤回操作 |
| 45 | // 白板延迟 | 45 | // 白板延迟 |
| 46 | - // this._apeDelayed = true; | ||
| 47 | - | ||
| 48 | //Ape Models | 46 | //Ape Models |
| 49 | this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); | 47 | this.registerKey(this._session_id, this._session_name, this._session_tag, new ArrayBuffer); |
| 50 | this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.WHITEBOARD_OBJ_TABLE_ID, | 48 | this.registerObj(pdu.RCPDU_REG_REGISTER_TABLE, ApeConsts.WHITEBOARD_OBJ_TABLE_ID, |
| @@ -17,187 +17,199 @@ import EngineUtils from 'EngineUtils'; | @@ -17,187 +17,199 @@ import EngineUtils from 'EngineUtils'; | ||
| 17 | let loger = Loger.getLoger('MCU'); | 17 | let loger = Loger.getLoger('MCU'); |
| 18 | 18 | ||
| 19 | class MCU extends Emiter { | 19 | class MCU extends Emiter { |
| 20 | - constructor() { | ||
| 21 | - super(); | ||
| 22 | - this._apes = {}; | ||
| 23 | - this._everSocket = everSocket; | ||
| 24 | - this._everSocket.on(everSocket.OPEN, this._everSocketOpenHandler.bind(this)); | ||
| 25 | - this._everSocket.on(everSocket.MESSAGE, this._everSocketMsgReceivedHandler.bind(this)); | ||
| 26 | - this._everSocket.on(everSocket.CLOSED, this._everSocketCloseHandler.bind(this)); | ||
| 27 | - } | ||
| 28 | - | ||
| 29 | - // 注册Ape | ||
| 30 | - registerApe(ape) { | ||
| 31 | - this._apes[ape._session_id] = ape; | ||
| 32 | - } | ||
| 33 | - | ||
| 34 | - // EverSocket建立通道完毕 | ||
| 35 | - _everSocketOpenHandler() { | ||
| 36 | - this._sendJoinClassRequest(); | ||
| 37 | - } | ||
| 38 | - // EverSocket连接断开 | ||
| 39 | - _everSocketCloseHandler() { | ||
| 40 | - GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_3); | ||
| 41 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_SOCKET_DISCONNECT); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - | ||
| 45 | - //MCU-发送加入课堂请求 | ||
| 46 | - _sendJoinClassRequest(){ | ||
| 47 | - //const classInfo = this.classInfo; | ||
| 48 | - loger.log('MCU-发送加入课堂请求.'); | ||
| 49 | - loger.log(this.classInfo); | ||
| 50 | - var descriptorPdu = new pdu['RCConferenceDescriptorPdu']; | ||
| 51 | - descriptorPdu.id = this.classInfo.classId; | ||
| 52 | - descriptorPdu.name = this.classInfo.className||""; | ||
| 53 | - descriptorPdu.mode = 0; | ||
| 54 | - descriptorPdu.capacity = 1; | ||
| 55 | - | ||
| 56 | - var joinRequestPdu = new pdu['RCConferenceJoinRequestPdu']; | ||
| 57 | - joinRequestPdu.type = 2; | ||
| 58 | - joinRequestPdu.initiator = this.classInfo.nodeId; | ||
| 59 | - joinRequestPdu.nodeType = PduConsts.NT_TERMINAL; //normal | ||
| 60 | - joinRequestPdu.classDescription = descriptorPdu;// classDescription | ||
| 61 | - | ||
| 62 | - let pduMsg = pdu.create_join_class_request_pdu( | ||
| 63 | - joinRequestPdu.type, | ||
| 64 | - this.classInfo.nodeId, | ||
| 65 | - this.classInfo.classId, | ||
| 66 | - 0, | ||
| 67 | - ApeConsts.BROADCAST_CHANNEL_ID, | ||
| 68 | - true, | ||
| 69 | - PduConsts.DP_TOP, | ||
| 70 | - this.classInfo.topNodeID, | ||
| 71 | - PduConsts.SEG_ONCE | ||
| 72 | - ); | ||
| 73 | - | ||
| 74 | - pduMsg.set("site", this.classInfo.siteId);//课堂号对应的名称 | ||
| 75 | - pduMsg.set("userId", this.classInfo.userId); | ||
| 76 | - pduMsg.set("userName", Base64.fromByteArray(ArrayBufferUtil.strToUint8Array(this.classInfo.userName))); | ||
| 77 | - pduMsg.set("userRole", this.classInfo.userRole); | ||
| 78 | - pduMsg.set("deviceType",""+GlobalConfig.deviceType); | ||
| 79 | - pduMsg.set("data", joinRequestPdu.toArrayBuffer()); | ||
| 80 | - | ||
| 81 | - this._everSocket.send(pduMsg.toArrayBuffer()); | ||
| 82 | - } | ||
| 83 | - | ||
| 84 | - // EverSocket底层消息处理 | ||
| 85 | - _everSocketMsgReceivedHandler(data) { | ||
| 86 | - let pduMsg = pdu.decode_pdu(data); | ||
| 87 | - let pduType = pduMsg.get("type"); | ||
| 88 | - let pduData = pduMsg.get("data"); | ||
| 89 | - //loger.data('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId); | ||
| 90 | - //loger.log('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId); | ||
| 91 | - switch (pduType) { | ||
| 92 | - case PduType.RCPDU_CONNECT_PROVIDER_RESPONSE: | ||
| 93 | - //加入课堂请求返回数据处理 | ||
| 94 | - let joinConfPdu = pdu['RCConferenceJoinResponsePdu'].decode(pduData); | ||
| 95 | - let pduResultCode = joinConfPdu.result; | ||
| 96 | - loger.warn( 'RCPDU_CONNECT_PROVIDER_RESPONSE ->pduResultCode:'+pduResultCode); | ||
| 97 | - switch (pduResultCode) { | ||
| 98 | - case PduConsts.RET_SUCCESS: | ||
| 99 | - //加入成功 | ||
| 100 | - this._updateMCUConfInfoDescription(joinConfPdu.classDescription); | ||
| 101 | - this._emit(MessageTypes.CLASS_JOIN_MCU_SUCCESS, this.classInfo); | ||
| 102 | - break; | ||
| 103 | - case PduConsts.RET_FULL_CAPACITY: | ||
| 104 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_CLASS_JOIN_FULL); | ||
| 105 | - //this._emit(MessageTypes.CLASS_JOIN_FAILED,MessageTypes.ERR_CLASS_JOIN_FULL); | ||
| 106 | - //this._emit(MessageTypes.CLASS_JOIN_FULL); | ||
| 107 | - break; | ||
| 108 | - default: | ||
| 109 | - loger.arn('JoinConfPdu-未知类型-等待处理.', pduResultCode); | ||
| 110 | - break | 20 | + constructor() { |
| 21 | + super(); | ||
| 22 | + this._apes = {}; | ||
| 23 | + this._everSocket = everSocket; | ||
| 24 | + this._everSocket.on(everSocket.OPEN, this._everSocketOpenHandler.bind(this)); | ||
| 25 | + this._everSocket.on(everSocket.MESSAGE, this._everSocketMsgReceivedHandler.bind(this)); | ||
| 26 | + this._everSocket.on(everSocket.CLOSED, this._everSocketCloseHandler.bind(this)); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + // 注册Ape | ||
| 30 | + registerApe(ape) { | ||
| 31 | + this._apes[ape._session_id] = ape; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + // EverSocket建立通道完毕 | ||
| 35 | + _everSocketOpenHandler() { | ||
| 36 | + this._sendJoinClassRequest(); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + // EverSocket连接断开 | ||
| 40 | + _everSocketCloseHandler() { | ||
| 41 | + GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_3); | ||
| 42 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_SOCKET_DISCONNECT); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + //MCU-发送加入课堂请求 | ||
| 47 | + _sendJoinClassRequest() { | ||
| 48 | + //const classInfo = this.classInfo; | ||
| 49 | + loger.log('MCU-发送加入课堂请求.'); | ||
| 50 | + loger.log(this.classInfo); | ||
| 51 | + var descriptorPdu = new pdu['RCConferenceDescriptorPdu']; | ||
| 52 | + descriptorPdu.id = this.classInfo.classId; | ||
| 53 | + descriptorPdu.name = this.classInfo.className || ""; | ||
| 54 | + descriptorPdu.mode = 0; | ||
| 55 | + descriptorPdu.capacity = 1; | ||
| 56 | + | ||
| 57 | + var joinRequestPdu = new pdu['RCConferenceJoinRequestPdu']; | ||
| 58 | + joinRequestPdu.type = 2; | ||
| 59 | + joinRequestPdu.initiator = this.classInfo.nodeId; | ||
| 60 | + joinRequestPdu.nodeType = PduConsts.NT_TERMINAL; //normal | ||
| 61 | + joinRequestPdu.classDescription = descriptorPdu;// classDescription | ||
| 62 | + | ||
| 63 | + let pduMsg = pdu.create_join_class_request_pdu( | ||
| 64 | + joinRequestPdu.type, | ||
| 65 | + this.classInfo.nodeId, | ||
| 66 | + this.classInfo.classId, | ||
| 67 | + 0, | ||
| 68 | + ApeConsts.BROADCAST_CHANNEL_ID, | ||
| 69 | + true, | ||
| 70 | + PduConsts.DP_TOP, | ||
| 71 | + this.classInfo.topNodeID, | ||
| 72 | + PduConsts.SEG_ONCE | ||
| 73 | + ); | ||
| 74 | + | ||
| 75 | + pduMsg.set("site", this.classInfo.siteId);//课堂号对应的名称 | ||
| 76 | + pduMsg.set("userId", this.classInfo.userId); | ||
| 77 | + pduMsg.set("userName", Base64.fromByteArray(ArrayBufferUtil.strToUint8Array(this.classInfo.userName))); | ||
| 78 | + pduMsg.set("userRole", this.classInfo.userRole); | ||
| 79 | + pduMsg.set("deviceType", "" + GlobalConfig.deviceType); | ||
| 80 | + pduMsg.set("data", joinRequestPdu.toArrayBuffer()); | ||
| 81 | + | ||
| 82 | + this._everSocket.send(pduMsg.toArrayBuffer()); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + // EverSocket底层消息处理 | ||
| 86 | + _everSocketMsgReceivedHandler(data) { | ||
| 87 | + let pduMsg = pdu.decode_pdu(data); | ||
| 88 | + let pduType = pduMsg.get("type"); | ||
| 89 | + let pduData = pduMsg.get("data"); | ||
| 90 | + //loger.data('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId); | ||
| 91 | + //loger.log('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId); | ||
| 92 | + switch (pduType) { | ||
| 93 | + case PduType.RCPDU_CONNECT_PROVIDER_RESPONSE: | ||
| 94 | + //加入课堂请求返回数据处理 | ||
| 95 | + let joinConfPdu = pdu['RCConferenceJoinResponsePdu'].decode(pduData); | ||
| 96 | + let pduResultCode = joinConfPdu.result; | ||
| 97 | + loger.warn('RCPDU_CONNECT_PROVIDER_RESPONSE ->pduResultCode:' + pduResultCode); | ||
| 98 | + switch (pduResultCode) { | ||
| 99 | + case PduConsts.RET_SUCCESS: | ||
| 100 | + //加入成功 | ||
| 101 | + this._updateMCUConfInfoDescription(joinConfPdu.classDescription); | ||
| 102 | + this._emit(MessageTypes.CLASS_JOIN_MCU_SUCCESS, this.classInfo); | ||
| 103 | + break; | ||
| 104 | + case PduConsts.RET_FULL_CAPACITY: | ||
| 105 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_CLASS_JOIN_FULL); | ||
| 106 | + //this._emit(MessageTypes.CLASS_JOIN_FAILED,MessageTypes.ERR_CLASS_JOIN_FULL); | ||
| 107 | + //this._emit(MessageTypes.CLASS_JOIN_FULL); | ||
| 108 | + break; | ||
| 109 | + default: | ||
| 110 | + loger.arn('JoinConfPdu-未知类型-等待处理.', pduResultCode); | ||
| 111 | + break | ||
| 112 | + } | ||
| 113 | + break; | ||
| 114 | + case PduType.RCPDU_SEND_DATA_REQUEST: | ||
| 115 | + //先判断当前消息属于哪个APE 根据 sessionId来判断 | ||
| 116 | + let ape = this._apes[pduMsg.sessionId]; | ||
| 117 | + let sessionLabel = ApeConsts(pduMsg.sessionId); | ||
| 118 | + if (ape) { | ||
| 119 | + let subTypeLabel = pdu.id2type(pduMsg.subType); | ||
| 120 | + //loger.log('MCU-SecondLayer封装消息', 'sessionId', sessionLabel, pduMsg.sessionId, 'subtype', subTypeLabel, pduMsg.subType); | ||
| 121 | + | ||
| 122 | + loger.warn('MCU->收到消息处理->', GlobalConfig.mcuDelay, GlobalConfig.messageDelay); | ||
| 123 | + //延迟处理消息(3个条件--->ape允许延迟&&客户端设置需要延迟&&Sass设置的延迟时间大于0) | ||
| 124 | + if (ape._apeDelayed && GlobalConfig.messageDelay && GlobalConfig.mcuDelay > 0) { | ||
| 125 | + loger.warn('延迟处理消息->', GlobalConfig.mcuDelay); | ||
| 126 | + setTimeout(() => { | ||
| 127 | + //this._pduRegAdapterHandler(regBuffer, seekTime); | ||
| 128 | + ape._emit(pduMsg.subType, pduMsg.data); | ||
| 129 | + }, GlobalConfig.mcuDelay * 1000);//mcuDelay单位是秒, | ||
| 130 | + // 这里需要换算为毫秒 | ||
| 131 | + return; | ||
| 132 | + } | ||
| 133 | + ape._emit(pduMsg.subType, pduMsg.data); | ||
| 134 | + } else { | ||
| 135 | + loger.warn(sessionLabel + '尚未注册'); | ||
| 136 | + } | ||
| 137 | + break; | ||
| 138 | + default: | ||
| 139 | + loger.warn('PDU-未知类型-等待处理.', pduType); | ||
| 111 | } | 140 | } |
| 112 | - break; | ||
| 113 | - case PduType.RCPDU_SEND_DATA_REQUEST: | ||
| 114 | - //先判断当前消息属于哪个APE 根据 sessionId来判断 | ||
| 115 | - let ape = this._apes[pduMsg.sessionId]; | ||
| 116 | - let sessionLabel = ApeConsts(pduMsg.sessionId); | ||
| 117 | - if (ape) { | ||
| 118 | - let subTypeLabel = pdu.id2type(pduMsg.subType); | ||
| 119 | - //loger.log('MCU-SecondLayer封装消息', 'sessionId', sessionLabel, pduMsg.sessionId, 'subtype', subTypeLabel, pduMsg.subType); | ||
| 120 | - //ape广播事件,只要ape中监听就能收到 | ||
| 121 | - ape._emit(pduMsg.subType, pduMsg.data); | ||
| 122 | - } else { | ||
| 123 | - loger.warn(sessionLabel + '尚未注册'); | ||
| 124 | - } | ||
| 125 | - break; | ||
| 126 | - default: | ||
| 127 | - loger.warn('PDU-未知类型-等待处理.', pduType); | ||
| 128 | } | 141 | } |
| 129 | - } | ||
| 130 | - | ||
| 131 | - _updateMCUConfInfoDescription(_data) { | ||
| 132 | - // let _mcuConfDesc=new pdu['RCConferenceDescriptorPdu'].decode(mcuConfDesc); | ||
| 133 | - loger.log('_updateMCUConfInfoDescription.'); | ||
| 134 | - //let classDescription=new pdu['RCConferenceDescriptorPdu'].decode(_data); | ||
| 135 | - loger.log(_data); | ||
| 136 | - //let info = this.mcuClassInfo.info; | ||
| 137 | - //info._conference_name = ArrayBufferUtil.uint8ArrayToStr(mcuConfDesc.name, 0); | ||
| 138 | - //info._capacity = mcuConfDesc.capacity; | ||
| 139 | - //info._mode = mcuConfDesc.mode; | ||
| 140 | - } | ||
| 141 | - | ||
| 142 | - // MU服务是否连接 | ||
| 143 | - get connected() { | ||
| 144 | - if (this._everSocket && this._everSocket.connected) | ||
| 145 | - return true; | ||
| 146 | - return false; | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - // 课堂发送消息 -- 消息同意序列号 | ||
| 150 | - send(msg) { | ||
| 151 | - if (this.connected) { | ||
| 152 | - loger.log('MCU-发送课堂数据....'); | ||
| 153 | - this._everSocket.send(msg.toArrayBuffer()); | ||
| 154 | - } else { | ||
| 155 | - loger.log('MCU-发送课堂数据失败,MCU底层通道不可用'); | ||
| 156 | - this._emit(MessageTypes.MCU_ERROR,MessageTypes.ERR_SOCKET_DISCONNECT); | 142 | + |
| 143 | + _updateMCUConfInfoDescription(_data) { | ||
| 144 | + // let _mcuConfDesc=new pdu['RCConferenceDescriptorPdu'].decode(mcuConfDesc); | ||
| 145 | + loger.log('_updateMCUConfInfoDescription.'); | ||
| 146 | + //let classDescription=new pdu['RCConferenceDescriptorPdu'].decode(_data); | ||
| 147 | + loger.log(_data); | ||
| 148 | + //let info = this.mcuClassInfo.info; | ||
| 149 | + //info._conference_name = ArrayBufferUtil.uint8ArrayToStr(mcuConfDesc.name, 0); | ||
| 150 | + //info._capacity = mcuConfDesc.capacity; | ||
| 151 | + //info._mode = mcuConfDesc.mode; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + // MU服务是否连接 | ||
| 155 | + get connected() { | ||
| 156 | + if (this._everSocket && this._everSocket.connected) | ||
| 157 | + return true; | ||
| 158 | + return false; | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + // 课堂发送消息 -- 消息同意序列号 | ||
| 162 | + send(msg) { | ||
| 163 | + if (this.connected) { | ||
| 164 | + loger.log('MCU-发送课堂数据....'); | ||
| 165 | + this._everSocket.send(msg.toArrayBuffer()); | ||
| 166 | + } else { | ||
| 167 | + loger.log('MCU-发送课堂数据失败,MCU底层通道不可用'); | ||
| 168 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_SOCKET_DISCONNECT); | ||
| 169 | + } | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + // 主动断开MCU连接 | ||
| 173 | + leaveMCU() { | ||
| 174 | + for (let ape in this._apes) { | ||
| 175 | + this._apes[ape].stopApe(); | ||
| 176 | + } | ||
| 177 | + loger.log('leaveMCU'); | ||
| 178 | + GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_3); | ||
| 179 | + this._everSocket.end(); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + // 主动建立MCU连接 | ||
| 183 | + joinMCU(_classInfo) { | ||
| 184 | + loger.log('开始建立EverSocket通道.'); | ||
| 185 | + loger.log(_classInfo); | ||
| 186 | + _classInfo.classId = parseInt(_classInfo.classId); // classId 必须整形 | ||
| 187 | + this.classInfo = _classInfo; | ||
| 188 | + // 创建刷新nodeId | ||
| 189 | + this.classInfo.nodeId = EngineUtils.creatSoleNumberFromTimestamp(); | ||
| 190 | + GlobalConfig.nodeId = this.classInfo.nodeId;//这是标识自己身份的id | ||
| 191 | + | ||
| 192 | + let nodeInfoRecordPdu = new pdu['RCNodeInfoRecordPdu']; | ||
| 193 | + nodeInfoRecordPdu.name = this.classInfo.userName; | ||
| 194 | + nodeInfoRecordPdu.nodeId = this.classInfo.nodeId; | ||
| 195 | + nodeInfoRecordPdu.userId = this.classInfo.userId; | ||
| 196 | + nodeInfoRecordPdu.role = ApeConsts.userTypesToId[this.classInfo.userRole] || 1; //NR_NORMAL用户的身份,根据用户登录时的身份设置 | ||
| 197 | + nodeInfoRecordPdu.level = 0; | ||
| 198 | + | ||
| 199 | + let conferenceRecord = {}; //RCConferenceRecord_T | ||
| 200 | + conferenceRecord._conference_id = this.classInfo.classId; | ||
| 201 | + conferenceRecord._top_node_id = this.classInfo.topNodeID; | ||
| 202 | + | ||
| 203 | + this.mcuClassInfo = {}; //RCMeetingInfo_T | ||
| 204 | + this.mcuClassInfo.self = nodeInfoRecordPdu; | ||
| 205 | + this.mcuClassInfo.info = conferenceRecord; | ||
| 206 | + | ||
| 207 | + // 内部mcuConfInfo | ||
| 208 | + this.classInfo.mcuClassInfo = this.mcuClassInfo; | ||
| 209 | + | ||
| 210 | + //开启EverSocket | ||
| 211 | + this._everSocket.begin(this.classInfo.MCUServerIP, this.classInfo.MCUServerPort); | ||
| 157 | } | 212 | } |
| 158 | - } | ||
| 159 | - | ||
| 160 | - // 主动断开MCU连接 | ||
| 161 | - leaveMCU() { | ||
| 162 | - for (let ape in this._apes) { | ||
| 163 | - this._apes[ape].stopApe(); | ||
| 164 | - } | ||
| 165 | - loger.log('leaveMCU'); | ||
| 166 | - GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_3); | ||
| 167 | - this._everSocket.end(); | ||
| 168 | - } | ||
| 169 | - | ||
| 170 | - // 主动建立MCU连接 | ||
| 171 | - joinMCU(_classInfo) { | ||
| 172 | - loger.log('开始建立EverSocket通道.'); | ||
| 173 | - loger.log(_classInfo); | ||
| 174 | - _classInfo.classId = parseInt(_classInfo.classId); // classId 必须整形 | ||
| 175 | - this.classInfo = _classInfo; | ||
| 176 | - // 创建刷新nodeId | ||
| 177 | - this.classInfo.nodeId =EngineUtils.creatSoleNumberFromTimestamp(); | ||
| 178 | - GlobalConfig.nodeId=this.classInfo.nodeId;//这是标识自己身份的id | ||
| 179 | - | ||
| 180 | - let nodeInfoRecordPdu = new pdu['RCNodeInfoRecordPdu']; | ||
| 181 | - nodeInfoRecordPdu.name = this.classInfo.userName; | ||
| 182 | - nodeInfoRecordPdu.nodeId = this.classInfo.nodeId; | ||
| 183 | - nodeInfoRecordPdu.userId = this.classInfo.userId; | ||
| 184 | - nodeInfoRecordPdu.role = ApeConsts.userTypesToId[this.classInfo.userRole]||1; //NR_NORMAL用户的身份,根据用户登录时的身份设置 | ||
| 185 | - nodeInfoRecordPdu.level = 0; | ||
| 186 | - | ||
| 187 | - let conferenceRecord = {}; //RCConferenceRecord_T | ||
| 188 | - conferenceRecord._conference_id = this.classInfo.classId; | ||
| 189 | - conferenceRecord._top_node_id =this.classInfo.topNodeID; | ||
| 190 | - | ||
| 191 | - this.mcuClassInfo = {}; //RCMeetingInfo_T | ||
| 192 | - this.mcuClassInfo.self = nodeInfoRecordPdu; | ||
| 193 | - this.mcuClassInfo.info = conferenceRecord; | ||
| 194 | - | ||
| 195 | - // 内部mcuConfInfo | ||
| 196 | - this.classInfo.mcuClassInfo = this.mcuClassInfo; | ||
| 197 | - | ||
| 198 | - //开启EverSocket | ||
| 199 | - this._everSocket.begin(this.classInfo.MCUServerIP,this.classInfo.MCUServerPort); | ||
| 200 | - } | ||
| 201 | } | 213 | } |
| 202 | 214 | ||
| 203 | export default new MCU; | 215 | export default new MCU; |
-
请 注册 或 登录 后发表评论