正在显示
4 个修改的文件
包含
221 行增加
和
212 行删除
此 diff 太大无法显示。
| @@ -21,6 +21,7 @@ | @@ -21,6 +21,7 @@ | ||
| 21 | "iscroll": "^5.2.0", | 21 | "iscroll": "^5.2.0", |
| 22 | "jquery": "^3.1.0", | 22 | "jquery": "^3.1.0", |
| 23 | "jquery-touchswipe": "^1.6.15", | 23 | "jquery-touchswipe": "^1.6.15", |
| 24 | + "mdetect": "^1.2.3", | ||
| 24 | "protobufjs": "^5.0.1", | 25 | "protobufjs": "^5.0.1", |
| 25 | "string.fromcodepoint": "^0.2.1", | 26 | "string.fromcodepoint": "^0.2.1", |
| 26 | "url-parse": "^1.1.1", | 27 | "url-parse": "^1.1.1", |
| @@ -31,9 +32,9 @@ | @@ -31,9 +32,9 @@ | ||
| 31 | "wbp": { | 32 | "wbp": { |
| 32 | "project": "umd", | 33 | "project": "umd", |
| 33 | "entries": { | 34 | "entries": { |
| 34 | - "McuClient": "./McuClientEngine.js" | 35 | + "McuClient": "./src/McuClientEngine.js" |
| 35 | }, | 36 | }, |
| 36 | "source": "src/", | 37 | "source": "src/", |
| 37 | "build": "dist/" | 38 | "build": "dist/" |
| 38 | } | 39 | } |
| 39 | -} | ||
| 40 | +} |
| 1 | -/*eslint-disable*/ | 1 | +/*eslint-disable*/ ; |
| 2 | 2 | ||
| 3 | import Emiter from 'Emiter'; | 3 | import Emiter from 'Emiter'; |
| 4 | import MessageTypes from 'MessageTypes'; | 4 | import MessageTypes from 'MessageTypes'; |
| @@ -17,233 +17,240 @@ import EngineUtils from 'EngineUtils'; | @@ -17,233 +17,240 @@ 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 | - this._everSocket.on(everSocket.ERROR, this._everSocketErrorHandler.bind(this)); | ||
| 28 | - } | 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 | + this._everSocket.on(everSocket.ERROR, this._everSocketErrorHandler.bind(this)); | ||
| 28 | + } | ||
| 29 | 29 | ||
| 30 | - // 注册Ape | ||
| 31 | - registerApe(ape) { | ||
| 32 | - this._apes[ape._session_id] = ape; | ||
| 33 | - } | 30 | + // 注册Ape |
| 31 | + registerApe(ape) { | ||
| 32 | + this._apes[ape._session_id] = ape; | ||
| 33 | + } | ||
| 34 | 34 | ||
| 35 | - // EverSocket建立通道完毕 | ||
| 36 | - _everSocketOpenHandler() { | ||
| 37 | - this._sendJoinClassRequest(); | ||
| 38 | - } | 35 | + // EverSocket建立通道完毕 |
| 36 | + _everSocketOpenHandler() { | ||
| 37 | + this._sendJoinClassRequest(); | ||
| 38 | + } | ||
| 39 | 39 | ||
| 40 | - // EverSocket连接断开 | ||
| 41 | - _everSocketCloseHandler() { | ||
| 42 | - //如果已经是断开状态,不需要多次发送异常消息 | ||
| 43 | - if (GlobalConfig.getCurrentStatus().code == GlobalConfig.statusCode_3.code) { | ||
| 44 | - loger.warn('已经断开连接->'); | ||
| 45 | - return; | ||
| 46 | - } | ||
| 47 | - GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_3); | ||
| 48 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_SOCKET_DISCONNECT); | 40 | + // EverSocket连接断开 |
| 41 | + _everSocketCloseHandler() { | ||
| 42 | + //如果已经是断开状态,不需要多次发送异常消息 | ||
| 43 | + if (GlobalConfig.getCurrentStatus().code == GlobalConfig.statusCode_3.code) { | ||
| 44 | + loger.warn('已经断开连接->'); | ||
| 45 | + return; | ||
| 49 | } | 46 | } |
| 47 | + GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_3); | ||
| 48 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_SOCKET_DISCONNECT); | ||
| 49 | + } | ||
| 50 | 50 | ||
| 51 | - //EverSocket错误异常 | ||
| 52 | - _everSocketErrorHandler(_errorCode) { | ||
| 53 | - //this._emit(MessageTypes.MCU_ERROR, _errorCode); | ||
| 54 | - //如果自动重连次数已经达到最大值,重新选点 | ||
| 55 | - if (_errorCode == everSocket.ERR_SOCKET_RECONNECT_FAILED) { | ||
| 56 | - this._emit(MessageTypes.SWITCH_MCU_IP); | ||
| 57 | - } | 51 | + //EverSocket错误异常 |
| 52 | + _everSocketErrorHandler(_errorCode) { | ||
| 53 | + //this._emit(MessageTypes.MCU_ERROR, _errorCode); | ||
| 54 | + //如果自动重连次数已经达到最大值,重新选点 | ||
| 55 | + if (_errorCode == everSocket.ERR_SOCKET_RECONNECT_FAILED) { | ||
| 56 | + this._emit(MessageTypes.SWITCH_MCU_IP); | ||
| 58 | } | 57 | } |
| 58 | + } | ||
| 59 | 59 | ||
| 60 | - //MCU-发送加入课堂请求 | ||
| 61 | - _sendJoinClassRequest() { | ||
| 62 | - //const classInfo = this.classInfo; | ||
| 63 | - loger.log('MCU-发送加入课堂请求.'); | ||
| 64 | - loger.log(this.classInfo); | ||
| 65 | - var descriptorPdu = new pdu['RCConferenceDescriptorPdu']; | ||
| 66 | - descriptorPdu.id = this.classInfo.classId; | ||
| 67 | - descriptorPdu.name = this.classInfo.className || ""; | ||
| 68 | - descriptorPdu.mode = 0; | ||
| 69 | - descriptorPdu.capacity = 1; | ||
| 70 | - | ||
| 71 | - var joinRequestPdu = new pdu['RCConferenceJoinRequestPdu']; | ||
| 72 | - joinRequestPdu.type = 2; | ||
| 73 | - joinRequestPdu.initiator = this.classInfo.nodeId; | ||
| 74 | - joinRequestPdu.nodeType = PduConsts.NT_TERMINAL; //normal | ||
| 75 | - joinRequestPdu.classDescription = descriptorPdu;// classDescription | ||
| 76 | - | ||
| 77 | - let pduMsg = pdu.create_join_class_request_pdu( | ||
| 78 | - joinRequestPdu.type, | ||
| 79 | - this.classInfo.nodeId, | ||
| 80 | - this.classInfo.classId, | ||
| 81 | - 0, | ||
| 82 | - ApeConsts.BROADCAST_CHANNEL_ID, | ||
| 83 | - true, | ||
| 84 | - PduConsts.DP_TOP, | ||
| 85 | - this.classInfo.topNodeID, | ||
| 86 | - PduConsts.SEG_ONCE | ||
| 87 | - ); | ||
| 88 | - | ||
| 89 | - pduMsg.set("site", this.classInfo.siteId);//课堂号对应的名称 | ||
| 90 | - pduMsg.set("userId", this.classInfo.userId); | ||
| 91 | - pduMsg.set("userName", Base64.fromByteArray(ArrayBufferUtil.strToUint8Array(this.classInfo.userName))); | ||
| 92 | - pduMsg.set("userRole", this.classInfo.userRole); | ||
| 93 | - pduMsg.set("deviceType", "" + GlobalConfig.deviceType); | ||
| 94 | - pduMsg.set("data", joinRequestPdu.toArrayBuffer()); | ||
| 95 | - | ||
| 96 | - this._everSocket.send(pduMsg.toArrayBuffer()); | ||
| 97 | - } | 60 | + //MCU-发送加入课堂请求 |
| 61 | + _sendJoinClassRequest() { | ||
| 62 | + //const classInfo = this.classInfo; | ||
| 63 | + loger.log('MCU-发送加入课堂请求.'); | ||
| 64 | + loger.log(this.classInfo); | ||
| 65 | + var descriptorPdu = new pdu['RCConferenceDescriptorPdu']; | ||
| 66 | + descriptorPdu.id = this.classInfo.classId; | ||
| 67 | + descriptorPdu.name = this.classInfo.className || ""; | ||
| 68 | + descriptorPdu.mode = 0; | ||
| 69 | + descriptorPdu.capacity = 1; | ||
| 98 | 70 | ||
| 99 | - // EverSocket底层消息处理 | ||
| 100 | - _everSocketMsgReceivedHandler(data) { | ||
| 101 | - let pduMsg = pdu.decode_pdu(data); | ||
| 102 | - let pduType = pduMsg.get("type"); | ||
| 103 | - let pduData = pduMsg.get("data"); | ||
| 104 | - //loger.data('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId); | ||
| 105 | - //loger.log('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId); | ||
| 106 | - switch (pduType) { | ||
| 107 | - case PduType.RCPDU_CONNECT_PROVIDER_RESPONSE: | ||
| 108 | - //加入课堂请求返回数据处理 | ||
| 109 | - let joinConfPdu = pdu['RCConferenceJoinResponsePdu'].decode(pduData); | ||
| 110 | - let pduResultCode = joinConfPdu.result; | ||
| 111 | - loger.warn('RCPDU_CONNECT_PROVIDER_RESPONSE ->pduResultCode:' + pduResultCode); | ||
| 112 | - switch (pduResultCode) { | ||
| 113 | - case PduConsts.RET_SUCCESS: | ||
| 114 | - //加入成功 | ||
| 115 | - this._updateMCUConfInfoDescription(joinConfPdu.classDescription); | ||
| 116 | - this._emit(MessageTypes.CLASS_JOIN_MCU_SUCCESS, this.classInfo); | ||
| 117 | - break; | ||
| 118 | - case PduConsts.RET_FULL_CAPACITY: | ||
| 119 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_CLASS_JOIN_FULL); | ||
| 120 | - //this._emit(MessageTypes.CLASS_JOIN_FAILED,MessageTypes.ERR_CLASS_JOIN_FULL); | ||
| 121 | - //this._emit(MessageTypes.CLASS_JOIN_FULL); | ||
| 122 | - break; | ||
| 123 | - default: | ||
| 124 | - loger.arn('JoinConfPdu-未知类型-等待处理.', pduResultCode); | ||
| 125 | - break | ||
| 126 | - } | ||
| 127 | - break; | ||
| 128 | - case PduType.RCPDU_SEND_DATA_REQUEST: | ||
| 129 | - //先判断当前消息属于哪个APE 根据 sessionId来判断 | ||
| 130 | - let ape = this._apes[pduMsg.sessionId]; | ||
| 131 | - let sessionLabel = ApeConsts(pduMsg.sessionId); | ||
| 132 | - if (ape) { | ||
| 133 | - let subTypeLabel = pdu.id2type(pduMsg.subType); | ||
| 134 | - //loger.log('MCU-SecondLayer封装消息', 'sessionId', sessionLabel, pduMsg.sessionId, 'subtype', subTypeLabel, pduMsg.subType); | ||
| 135 | - | ||
| 136 | - loger.warn('接收服务端消息----------------->subType->', pduMsg.subType, GlobalConfig.mcuDelay, GlobalConfig.messageDelay); | ||
| 137 | - //延迟处理消息(3个条件--->ape允许延迟&&客户端设置需要延迟&&Sass设置的延迟时间大于0) | ||
| 138 | - if (ape._apeDelayed && GlobalConfig.messageDelay && GlobalConfig.mcuDelay > 0) { | ||
| 139 | - loger.warn('延迟处理消息->', GlobalConfig.mcuDelay); | ||
| 140 | - setTimeout(() => { | ||
| 141 | - //this._pduRegAdapterHandler(regBuffer, seekTime); | ||
| 142 | - ape._emit(pduMsg.subType, pduMsg.data); | ||
| 143 | - }, GlobalConfig.mcuDelay * 1000);//mcuDelay单位是秒, | ||
| 144 | - // 这里需要换算为毫秒 | ||
| 145 | - return; | ||
| 146 | - } | ||
| 147 | - ape._emit(pduMsg.subType, pduMsg.data); | ||
| 148 | - } else { | ||
| 149 | - loger.warn(sessionLabel + '尚未注册'); | ||
| 150 | - } | ||
| 151 | - break; | ||
| 152 | - default: | ||
| 153 | - loger.warn('PDU-未知类型-等待处理.', pduType); | ||
| 154 | - } | ||
| 155 | - } | 71 | + var joinRequestPdu = new pdu['RCConferenceJoinRequestPdu']; |
| 72 | + joinRequestPdu.type = 2; | ||
| 73 | + joinRequestPdu.initiator = this.classInfo.nodeId; | ||
| 74 | + joinRequestPdu.nodeType = PduConsts.NT_TERMINAL; //normal | ||
| 75 | + joinRequestPdu.classDescription = descriptorPdu; // classDescription | ||
| 156 | 76 | ||
| 157 | - _updateMCUConfInfoDescription(_data) { | ||
| 158 | - // let _mcuConfDesc=new pdu['RCConferenceDescriptorPdu'].decode(mcuConfDesc); | ||
| 159 | - loger.log('_updateMCUConfInfoDescription.'); | ||
| 160 | - //let classDescription=new pdu['RCConferenceDescriptorPdu'].decode(_data); | ||
| 161 | - loger.log(_data); | ||
| 162 | - //let info = this.mcuClassInfo.info; | ||
| 163 | - //info._conference_name = ArrayBufferUtil.uint8ArrayToStr(mcuConfDesc.name, 0); | ||
| 164 | - //info._capacity = mcuConfDesc.capacity; | ||
| 165 | - //info._mode = mcuConfDesc.mode; | ||
| 166 | - } | 77 | + let pduMsg = pdu.create_join_class_request_pdu( |
| 78 | + joinRequestPdu.type, | ||
| 79 | + this.classInfo.nodeId, | ||
| 80 | + this.classInfo.classId, | ||
| 81 | + 0, | ||
| 82 | + ApeConsts.BROADCAST_CHANNEL_ID, | ||
| 83 | + true, | ||
| 84 | + PduConsts.DP_TOP, | ||
| 85 | + this.classInfo.topNodeID, | ||
| 86 | + PduConsts.SEG_ONCE | ||
| 87 | + ); | ||
| 167 | 88 | ||
| 168 | - // MU服务是否连接 | ||
| 169 | - get connected() { | ||
| 170 | - if (this._everSocket && this._everSocket.connected) | ||
| 171 | - return true; | ||
| 172 | - return false; | ||
| 173 | - } | 89 | + pduMsg.set("site", this.classInfo.siteId); //课堂号对应的名称 |
| 90 | + pduMsg.set("userId", this.classInfo.userId); | ||
| 91 | + pduMsg.set("userName", Base64.fromByteArray(ArrayBufferUtil.strToUint8Array(this.classInfo.userName))); | ||
| 92 | + pduMsg.set("userRole", this.classInfo.userRole); | ||
| 93 | + pduMsg.set("deviceType", "" + GlobalConfig.deviceType); | ||
| 94 | + pduMsg.set("data", joinRequestPdu.toArrayBuffer()); | ||
| 95 | + | ||
| 96 | + this._everSocket.send(pduMsg.toArrayBuffer()); | ||
| 97 | + } | ||
| 174 | 98 | ||
| 175 | - // 课堂发送消息 -- 消息同意序列号 | ||
| 176 | - send(msg) { | ||
| 177 | - if (this.connected) { | ||
| 178 | - loger.log('发送数据到服务端-------------------->'); | ||
| 179 | - this._everSocket.send(msg.toArrayBuffer()); | ||
| 180 | - } else { | ||
| 181 | - loger.log('发送数据到服务端-------------------->失败->未连接到服务端'); | ||
| 182 | - this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_SOCKET_DISCONNECT); | 99 | + // EverSocket底层消息处理 |
| 100 | + _everSocketMsgReceivedHandler(data) { | ||
| 101 | + let pduMsg = pdu.decode_pdu(data); | ||
| 102 | + let pduType = pduMsg.get("type"); | ||
| 103 | + let pduData = pduMsg.get("data"); | ||
| 104 | + //loger.data('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId); | ||
| 105 | + //loger.log('MCU-FirstLayer封装消息', 'type', pdu.id2type(pduMsg.type), pduMsg.type, 'sessionId', ApeConsts(pduMsg.sessionId), pduMsg.sessionId); | ||
| 106 | + switch (pduType) { | ||
| 107 | + case PduType.RCPDU_CONNECT_PROVIDER_RESPONSE: | ||
| 108 | + //加入课堂请求返回数据处理 | ||
| 109 | + let joinConfPdu = pdu['RCConferenceJoinResponsePdu'].decode(pduData); | ||
| 110 | + let pduResultCode = joinConfPdu.result; | ||
| 111 | + loger.warn('RCPDU_CONNECT_PROVIDER_RESPONSE ->pduResultCode:' + pduResultCode); | ||
| 112 | + switch (pduResultCode) { | ||
| 113 | + case PduConsts.RET_SUCCESS: | ||
| 114 | + //加入成功 | ||
| 115 | + this._updateMCUConfInfoDescription(joinConfPdu.classDescription); | ||
| 116 | + this._emit(MessageTypes.CLASS_JOIN_MCU_SUCCESS, this.classInfo); | ||
| 117 | + break; | ||
| 118 | + case PduConsts.RET_FULL_CAPACITY: | ||
| 119 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_CLASS_JOIN_FULL); | ||
| 120 | + //this._emit(MessageTypes.CLASS_JOIN_FAILED,MessageTypes.ERR_CLASS_JOIN_FULL); | ||
| 121 | + //this._emit(MessageTypes.CLASS_JOIN_FULL); | ||
| 122 | + break; | ||
| 123 | + default: | ||
| 124 | + loger.arn('JoinConfPdu-未知类型-等待处理.', pduResultCode); | ||
| 125 | + break | ||
| 126 | + } | ||
| 127 | + break; | ||
| 128 | + case PduType.RCPDU_SEND_DATA_REQUEST: | ||
| 129 | + //先判断当前消息属于哪个APE 根据 sessionId来判断 | ||
| 130 | + let ape = this._apes[pduMsg.sessionId]; | ||
| 131 | + let sessionLabel = ApeConsts(pduMsg.sessionId); | ||
| 132 | + if (ape) { | ||
| 133 | + let subTypeLabel = pdu.id2type(pduMsg.subType); | ||
| 134 | + loger.log('MCU-SecondLayer封装消息', | ||
| 135 | + 'sessionId', | ||
| 136 | + sessionLabel, | ||
| 137 | + pduMsg.sessionId, | ||
| 138 | + 'subtype', | ||
| 139 | + subTypeLabel, | ||
| 140 | + pduMsg.subType, | ||
| 141 | + GlobalConfig.mcuDelay, | ||
| 142 | + GlobalConfig.messageDelay); | ||
| 143 | + | ||
| 144 | + //延迟处理消息(3个条件--->ape允许延迟&&客户端设置需要延迟&&Sass设置的延迟时间大于0) | ||
| 145 | + if (GlobalConfig.messageDelay && GlobalConfig.messageDelay.indexOf(sessionLabel) !== -1 && GlobalConfig.mcuDelay > 0) { | ||
| 146 | + loger.warn('延迟处理消息->', GlobalConfig.mcuDelay); | ||
| 147 | + setTimeout(() => { | ||
| 148 | + //this._pduRegAdapterHandler(regBuffer, seekTime); | ||
| 149 | + ape._emit(pduMsg.subType, pduMsg.data); | ||
| 150 | + }, GlobalConfig.mcuDelay * 1000); //mcuDelay单位是秒, | ||
| 151 | + // 这里需要换算为毫秒 | ||
| 152 | + return; | ||
| 183 | } | 153 | } |
| 154 | + ape._emit(pduMsg.subType, pduMsg.data); | ||
| 155 | + } else { | ||
| 156 | + loger.warn(sessionLabel + '尚未注册'); | ||
| 157 | + } | ||
| 158 | + break; | ||
| 159 | + default: | ||
| 160 | + loger.warn('PDU-未知类型-等待处理.', pduType); | ||
| 184 | } | 161 | } |
| 162 | + } | ||
| 185 | 163 | ||
| 186 | - // 主动断开MCU连接 | ||
| 187 | - leaveMCU() { | ||
| 188 | - for (let ape in this._apes) { | ||
| 189 | - this._apes[ape].stopApe(); | ||
| 190 | - } | ||
| 191 | - loger.log('leaveMCU'); | ||
| 192 | - GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_3); | ||
| 193 | - GlobalConfig.classJoinSuccess=false; | ||
| 194 | - this._everSocket.end(); | 164 | + _updateMCUConfInfoDescription(_data) { |
| 165 | + // let _mcuConfDesc=new pdu['RCConferenceDescriptorPdu'].decode(mcuConfDesc); | ||
| 166 | + loger.log('_updateMCUConfInfoDescription.'); | ||
| 167 | + //let classDescription=new pdu['RCConferenceDescriptorPdu'].decode(_data); | ||
| 168 | + loger.log(_data); | ||
| 169 | + //let info = this.mcuClassInfo.info; | ||
| 170 | + //info._conference_name = ArrayBufferUtil.uint8ArrayToStr(mcuConfDesc.name, 0); | ||
| 171 | + //info._capacity = mcuConfDesc.capacity; | ||
| 172 | + //info._mode = mcuConfDesc.mode; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + // MU服务是否连接 | ||
| 176 | + get connected() { | ||
| 177 | + if (this._everSocket && this._everSocket.connected) | ||
| 178 | + return true; | ||
| 179 | + return false; | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + // 课堂发送消息 -- 消息同意序列号 | ||
| 183 | + send(msg) { | ||
| 184 | + if (this.connected) { | ||
| 185 | + loger.log('发送数据到服务端-------------------->'); | ||
| 186 | + this._everSocket.send(msg.toArrayBuffer()); | ||
| 187 | + } else { | ||
| 188 | + loger.log('发送数据到服务端-------------------->失败->未连接到服务端'); | ||
| 189 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_SOCKET_DISCONNECT); | ||
| 195 | } | 190 | } |
| 191 | + } | ||
| 196 | 192 | ||
| 197 | - // 主动建立MCU连接 | ||
| 198 | - joinMCU(_classInfo) { | ||
| 199 | - loger.log('开始建立EverSocket通道.'); | ||
| 200 | - GlobalConfig.classJoinSuccess=false; | ||
| 201 | - loger.log(_classInfo); | ||
| 202 | - _classInfo.classId = parseInt(_classInfo.classId); // classId 必须整形 | ||
| 203 | - this.classInfo = _classInfo; | ||
| 204 | - // 创建刷新nodeId | ||
| 205 | - this.classInfo.nodeId = EngineUtils.creatSoleNumberFromTimestamp(); | ||
| 206 | - GlobalConfig.nodeId = this.classInfo.nodeId;//这是标识自己身份的id | ||
| 207 | - | ||
| 208 | - let nodeInfoRecordPdu = new pdu['RCNodeInfoRecordPdu']; | ||
| 209 | - nodeInfoRecordPdu.name = this.classInfo.userName; | ||
| 210 | - nodeInfoRecordPdu.nodeId = this.classInfo.nodeId; | ||
| 211 | - nodeInfoRecordPdu.userId = this.classInfo.userId; | ||
| 212 | - nodeInfoRecordPdu.role = ApeConsts.userTypesToId[this.classInfo.userRole] || 1; //NR_NORMAL用户的身份,根据用户登录时的身份设置 | ||
| 213 | - nodeInfoRecordPdu.level = 0; | ||
| 214 | - nodeInfoRecordPdu.handUpTime=0; | ||
| 215 | - nodeInfoRecordPdu.openCamera=0; | ||
| 216 | - nodeInfoRecordPdu.openMicrophones=0; | ||
| 217 | - nodeInfoRecordPdu.microphones=GlobalConfig.microphones; | ||
| 218 | - nodeInfoRecordPdu.cameras=GlobalConfig.cameras; | ||
| 219 | - nodeInfoRecordPdu.videoQuality=GlobalConfig.videoQuality;//设置分辨率的 | ||
| 220 | - nodeInfoRecordPdu.userIp=GlobalConfig.userIp; | ||
| 221 | - | ||
| 222 | - let conferenceRecord = {}; //RCConferenceRecord_T | ||
| 223 | - conferenceRecord._conference_id = this.classInfo.classId; | ||
| 224 | - conferenceRecord._top_node_id = this.classInfo.topNodeID; | ||
| 225 | - | ||
| 226 | - this.mcuClassInfo = {}; //RCMeetingInfo_T | ||
| 227 | - this.mcuClassInfo.self = nodeInfoRecordPdu; | ||
| 228 | - this.mcuClassInfo.info = conferenceRecord; | ||
| 229 | - | ||
| 230 | - // 内部mcuConfInfo | ||
| 231 | - this.classInfo.mcuClassInfo = this.mcuClassInfo; | ||
| 232 | - | ||
| 233 | - //开启EverSocket | ||
| 234 | - this._everSocket.begin(this.classInfo.MCUServerIP, this.classInfo.MCUServerPort); | 193 | + // 主动断开MCU连接 |
| 194 | + leaveMCU() { | ||
| 195 | + for (let ape in this._apes) { | ||
| 196 | + this._apes[ape].stopApe(); | ||
| 235 | } | 197 | } |
| 198 | + loger.log('leaveMCU'); | ||
| 199 | + GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_3); | ||
| 200 | + GlobalConfig.classJoinSuccess = false; | ||
| 201 | + this._everSocket.end(); | ||
| 202 | + } | ||
| 236 | 203 | ||
| 237 | - //切换MCU的ip | ||
| 238 | - switchMCUIp(_classInfo) { | ||
| 239 | - if (_classInfo && _classInfo.MCUServerIP) { | ||
| 240 | - this.classInfo.MCUServerIP = _classInfo.MCUServerIP; | ||
| 241 | - this.classInfo.MCUServerPort = _classInfo.MCUServerPort; | ||
| 242 | - if (this._everSocket) { | ||
| 243 | - this._everSocket.switchSocketIp(this.classInfo.MCUServerIP, this.classInfo.MCUServerPort); | ||
| 244 | - } | ||
| 245 | - } | 204 | + // 主动建立MCU连接 |
| 205 | + joinMCU(_classInfo) { | ||
| 206 | + loger.log('开始建立EverSocket通道.'); | ||
| 207 | + GlobalConfig.classJoinSuccess = false; | ||
| 208 | + loger.log(_classInfo); | ||
| 209 | + _classInfo.classId = parseInt(_classInfo.classId); // classId 必须整形 | ||
| 210 | + this.classInfo = _classInfo; | ||
| 211 | + // 创建刷新nodeId | ||
| 212 | + this.classInfo.nodeId = EngineUtils.creatSoleNumberFromTimestamp(); | ||
| 213 | + GlobalConfig.nodeId = this.classInfo.nodeId; //这是标识自己身份的id | ||
| 214 | + | ||
| 215 | + let nodeInfoRecordPdu = new pdu['RCNodeInfoRecordPdu']; | ||
| 216 | + nodeInfoRecordPdu.name = this.classInfo.userName; | ||
| 217 | + nodeInfoRecordPdu.nodeId = this.classInfo.nodeId; | ||
| 218 | + nodeInfoRecordPdu.userId = this.classInfo.userId; | ||
| 219 | + nodeInfoRecordPdu.role = ApeConsts.userTypesToId[this.classInfo.userRole] || 1; //NR_NORMAL用户的身份,根据用户登录时的身份设置 | ||
| 220 | + nodeInfoRecordPdu.level = 0; | ||
| 221 | + nodeInfoRecordPdu.handUpTime = 0; | ||
| 222 | + nodeInfoRecordPdu.openCamera = 0; | ||
| 223 | + nodeInfoRecordPdu.openMicrophones = 0; | ||
| 224 | + nodeInfoRecordPdu.microphones = GlobalConfig.microphones; | ||
| 225 | + nodeInfoRecordPdu.cameras = GlobalConfig.cameras; | ||
| 226 | + nodeInfoRecordPdu.videoQuality = GlobalConfig.videoQuality; //设置分辨率的 | ||
| 227 | + nodeInfoRecordPdu.userIp = GlobalConfig.userIp; | ||
| 228 | + | ||
| 229 | + let conferenceRecord = {}; //RCConferenceRecord_T | ||
| 230 | + conferenceRecord._conference_id = this.classInfo.classId; | ||
| 231 | + conferenceRecord._top_node_id = this.classInfo.topNodeID; | ||
| 232 | + | ||
| 233 | + this.mcuClassInfo = {}; //RCMeetingInfo_T | ||
| 234 | + this.mcuClassInfo.self = nodeInfoRecordPdu; | ||
| 235 | + this.mcuClassInfo.info = conferenceRecord; | ||
| 236 | + | ||
| 237 | + // 内部mcuConfInfo | ||
| 238 | + this.classInfo.mcuClassInfo = this.mcuClassInfo; | ||
| 239 | + | ||
| 240 | + //开启EverSocket | ||
| 241 | + this._everSocket.begin(this.classInfo.MCUServerIP, this.classInfo.MCUServerPort); | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + //切换MCU的ip | ||
| 245 | + switchMCUIp(_classInfo) { | ||
| 246 | + if (_classInfo && _classInfo.MCUServerIP) { | ||
| 247 | + this.classInfo.MCUServerIP = _classInfo.MCUServerIP; | ||
| 248 | + this.classInfo.MCUServerPort = _classInfo.MCUServerPort; | ||
| 249 | + if (this._everSocket) { | ||
| 250 | + this._everSocket.switchSocketIp(this.classInfo.MCUServerIP, this.classInfo.MCUServerPort); | ||
| 251 | + } | ||
| 246 | } | 252 | } |
| 253 | + } | ||
| 247 | } | 254 | } |
| 248 | 255 | ||
| 249 | export default new MCU; | 256 | export default new MCU; |
| 1 | module.exports = function (umdConf) { | 1 | module.exports = function (umdConf) { |
| 2 | umdConf.devServer.host = '0.0.0.0'; | 2 | umdConf.devServer.host = '0.0.0.0'; |
| 3 | - //umdConf.webpackFeatures.enableEntryHTML();//生成 | 3 | + umdConf.devServer.port = '8282'; |
| 4 | + umdConf.webpackFeatures.enableEntryHTML('McuClient'); | ||
| 4 | umdConf.output.publicPath = ''; | 5 | umdConf.output.publicPath = ''; |
| 5 | umdConf.output.library = 'MCUClientEngine'; | 6 | umdConf.output.library = 'MCUClientEngine'; |
| 6 | 7 |
-
请 注册 或 登录 后发表评论