正在显示
14 个修改的文件
包含
291 行增加
和
211 行删除
此 diff 太大无法显示。
| @@ -141,7 +141,7 @@ export default class MessageEntrance extends Emiter { | @@ -141,7 +141,7 @@ export default class MessageEntrance extends Emiter { | ||
| 141 | this.getVideoPublishPath = this._getVideoPublishPath.bind(this); | 141 | this.getVideoPublishPath = this._getVideoPublishPath.bind(this); |
| 142 | this.getVideoAllChannelInfo = this._getVideoAllChannelInfo.bind(this); | 142 | this.getVideoAllChannelInfo = this._getVideoAllChannelInfo.bind(this); |
| 143 | this.publishVideo = this._publishVideo.bind(this); | 143 | this.publishVideo = this._publishVideo.bind(this); |
| 144 | - this.stopPublishVideo = this._stopPublishVideo.bind(this); | 144 | + this.stopPublishVideo =this.unPublishVideo= this._stopPublishVideo.bind(this); |
| 145 | this.sendVideoBroadcastMsg = this._sendVideoBroadcastMsg.bind(this); | 145 | this.sendVideoBroadcastMsg = this._sendVideoBroadcastMsg.bind(this); |
| 146 | 146 | ||
| 147 | 147 | ||
| @@ -150,7 +150,7 @@ export default class MessageEntrance extends Emiter { | @@ -150,7 +150,7 @@ export default class MessageEntrance extends Emiter { | ||
| 150 | this.getAudioPublishPath = this._getPublishAudioPath.bind(this); | 150 | this.getAudioPublishPath = this._getPublishAudioPath.bind(this); |
| 151 | this.getAudioAllChannelInfo = this._getAudioAllChannelInfo.bind(this); | 151 | this.getAudioAllChannelInfo = this._getAudioAllChannelInfo.bind(this); |
| 152 | this.publishAudio = this._publishAudio.bind(this); | 152 | this.publishAudio = this._publishAudio.bind(this); |
| 153 | - this.stopPublishAudio = this._stopPublishAudio.bind(this); | 153 | + this.stopPublishAudio =this.unPublishAudio= this._stopPublishAudio.bind(this); |
| 154 | this.sendAudioBroadcastMsg = this.sendAudioCommandMsg.bind(this); | 154 | this.sendAudioBroadcastMsg = this.sendAudioCommandMsg.bind(this); |
| 155 | 155 | ||
| 156 | //whiteBoradApe | 156 | //whiteBoradApe |
| @@ -296,10 +296,22 @@ export default class MessageEntrance extends Emiter { | @@ -296,10 +296,22 @@ export default class MessageEntrance extends Emiter { | ||
| 296 | GlobalConfig.isRecordPlayBack=false;//设置为非录制回放状态 | 296 | GlobalConfig.isRecordPlayBack=false;//设置为非录制回放状态 |
| 297 | GlobalConfig.classId = parseInt(_param.classId); | 297 | GlobalConfig.classId = parseInt(_param.classId); |
| 298 | GlobalConfig.portal = _param.portal; | 298 | GlobalConfig.portal = _param.portal; |
| 299 | - GlobalConfig.userRole = _param.userRole || ApeConsts.normal; | ||
| 300 | GlobalConfig.userId = _param.userId || "0"; | 299 | GlobalConfig.userId = _param.userId || "0"; |
| 301 | GlobalConfig.userName = _param.userName || ""; | 300 | GlobalConfig.userName = _param.userName || ""; |
| 302 | 301 | ||
| 302 | + //设置角色身份 | ||
| 303 | + GlobalConfig.userRole = _param.userRole || ApeConsts.normal; | ||
| 304 | + if(GlobalConfig.userRole!=ApeConsts.host&& | ||
| 305 | + GlobalConfig.userRole!=ApeConsts.presenter&& | ||
| 306 | + GlobalConfig.userRole!=ApeConsts.assistant&& | ||
| 307 | + GlobalConfig.userRole!=ApeConsts.record&& | ||
| 308 | + GlobalConfig.userRole!=ApeConsts.invisible){ | ||
| 309 | + GlobalConfig.userRole= ApeConsts.normal; | ||
| 310 | + } | ||
| 311 | + | ||
| 312 | + //客户端决定是否延迟接收消息 | ||
| 313 | + GlobalConfig.messageDelay = _param.messageDelay || false; | ||
| 314 | + | ||
| 303 | //最长允许录制的时间 | 315 | //最长允许录制的时间 |
| 304 | if(_param.allowRecordMaxTime){ | 316 | if(_param.allowRecordMaxTime){ |
| 305 | GlobalConfig.allowRecordMaxTime=parseInt(_param.allowRecordMaxTime); | 317 | GlobalConfig.allowRecordMaxTime=parseInt(_param.allowRecordMaxTime); |
| @@ -412,7 +424,7 @@ export default class MessageEntrance extends Emiter { | @@ -412,7 +424,7 @@ export default class MessageEntrance extends Emiter { | ||
| 412 | // console.log(_data); | 424 | // console.log(_data); |
| 413 | //包含整个课堂最全的信息,储存数据 | 425 | //包含整个课堂最全的信息,储存数据 |
| 414 | if (_data) { | 426 | if (_data) { |
| 415 | - GlobalConfig.mcuDelay = _data.mcuDelay || 60;//mcu消息延迟,用于文档模块 | 427 | + GlobalConfig.mcuDelay = _data.h5Delay || 0;//mcu消息延迟的时间间隔,单位(秒),结合客户端传的messageDelay的值使用 |
| 416 | GlobalConfig.className = _data.meetingName || ""; | 428 | GlobalConfig.className = _data.meetingName || ""; |
| 417 | GlobalConfig.classBeginTime = _data.beginTime || ""; | 429 | GlobalConfig.classBeginTime = _data.beginTime || ""; |
| 418 | GlobalConfig.classEndTime = _data.endTime || ""; | 430 | GlobalConfig.classEndTime = _data.endTime || ""; |
| @@ -421,6 +433,14 @@ export default class MessageEntrance extends Emiter { | @@ -421,6 +433,14 @@ export default class MessageEntrance extends Emiter { | ||
| 421 | GlobalConfig.maxVideoChannels = _data.maxVideoChannels; | 433 | GlobalConfig.maxVideoChannels = _data.maxVideoChannels; |
| 422 | GlobalConfig.maxAudioChannels = _data.maxAudioChannels; | 434 | GlobalConfig.maxAudioChannels = _data.maxAudioChannels; |
| 423 | 435 | ||
| 436 | + //视频质量相关设置 | ||
| 437 | + GlobalConfig.fps = _data.fps||15; | ||
| 438 | + GlobalConfig.gop = _data.gop||3;; | ||
| 439 | + GlobalConfig.videoQuality = _data.videoQuality||2; | ||
| 440 | + | ||
| 441 | + //是否自动开始(身份是host的时候才用到的) | ||
| 442 | + GlobalConfig.isAutoStartClass= _data.autoRecord||0; | ||
| 443 | + | ||
| 424 | GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表 | 444 | GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表 |
| 425 | GlobalConfig.setRecordList(_data.recordList);//录制回放地址 | 445 | GlobalConfig.setRecordList(_data.recordList);//录制回放地址 |
| 426 | GlobalConfig.setDocList(_data.docList);//文档地址 | 446 | GlobalConfig.setDocList(_data.docList);//文档地址 |
| @@ -592,6 +612,11 @@ export default class MessageEntrance extends Emiter { | @@ -592,6 +612,11 @@ export default class MessageEntrance extends Emiter { | ||
| 592 | 612 | ||
| 593 | joinClassSuccessCallBackData.classTimestamp=GlobalConfig.classTimestamp;//课堂进行的累积时间 | 613 | joinClassSuccessCallBackData.classTimestamp=GlobalConfig.classTimestamp;//课堂进行的累积时间 |
| 594 | joinClassSuccessCallBackData.recordPlaybackMaxTime=GlobalConfig.recordPlaybackMaxTime;//录制回放的总时间 | 614 | joinClassSuccessCallBackData.recordPlaybackMaxTime=GlobalConfig.recordPlaybackMaxTime;//录制回放的总时间 |
| 615 | + | ||
| 616 | + joinClassSuccessCallBackData.fps=GlobalConfig.fps; | ||
| 617 | + joinClassSuccessCallBackData.gop=GlobalConfig.gop; | ||
| 618 | + joinClassSuccessCallBackData.videoQuality=GlobalConfig.videoQuality; | ||
| 619 | + | ||
| 595 | loger.log('加入课堂成功'); | 620 | loger.log('加入课堂成功'); |
| 596 | loger.log(joinClassSuccessCallBackData); | 621 | loger.log(joinClassSuccessCallBackData); |
| 597 | 622 | ||
| @@ -1141,6 +1166,10 @@ export default class MessageEntrance extends Emiter { | @@ -1141,6 +1166,10 @@ export default class MessageEntrance extends Emiter { | ||
| 1141 | joinClassSuccessCallBackData.classTimestamp=GlobalConfig.classTimestamp;//课堂进行的累积时间 | 1166 | joinClassSuccessCallBackData.classTimestamp=GlobalConfig.classTimestamp;//课堂进行的累积时间 |
| 1142 | joinClassSuccessCallBackData.recordPlaybackMaxTime=GlobalConfig.recordPlaybackMaxTime;//录制回放的总时间 | 1167 | joinClassSuccessCallBackData.recordPlaybackMaxTime=GlobalConfig.recordPlaybackMaxTime;//录制回放的总时间 |
| 1143 | 1168 | ||
| 1169 | + joinClassSuccessCallBackData.fps=GlobalConfig.fps; | ||
| 1170 | + joinClassSuccessCallBackData.gop=GlobalConfig.gop; | ||
| 1171 | + joinClassSuccessCallBackData.videoQuality=GlobalConfig.videoQuality; | ||
| 1172 | + | ||
| 1144 | loger.log(joinClassSuccessCallBackData); | 1173 | loger.log(joinClassSuccessCallBackData); |
| 1145 | //和加入课堂成功使用同样的消息处理 | 1174 | //和加入课堂成功使用同样的消息处理 |
| 1146 | this._emit(MessageTypes.CLASS_JOIN_SUCCESS, joinClassSuccessCallBackData); | 1175 | this._emit(MessageTypes.CLASS_JOIN_SUCCESS, joinClassSuccessCallBackData); |
| @@ -52,6 +52,9 @@ class GlobalConfig { | @@ -52,6 +52,9 @@ class GlobalConfig { | ||
| 52 | classInfo.MCUServerPort=this.MCUServerPort; | 52 | classInfo.MCUServerPort=this.MCUServerPort; |
| 53 | classInfo.maxVideoChannels= this.maxVideoChannels; | 53 | classInfo.maxVideoChannels= this.maxVideoChannels; |
| 54 | classInfo.maxAudioChannels=this.maxAudioChannels; | 54 | classInfo.maxAudioChannels=this.maxAudioChannels; |
| 55 | + classInfo.fps=this.fps; | ||
| 56 | + classInfo.gop=this.gop; | ||
| 57 | + classInfo.videoQuality=this.videoQuality; | ||
| 55 | 58 | ||
| 56 | return classInfo; | 59 | return classInfo; |
| 57 | 60 | ||
| @@ -242,8 +245,10 @@ GlobalConfig.statusCode_4={"code":4,message:"未知状态"}; | @@ -242,8 +245,10 @@ GlobalConfig.statusCode_4={"code":4,message:"未知状态"}; | ||
| 242 | 245 | ||
| 243 | GlobalConfig.md5=""; | 246 | GlobalConfig.md5=""; |
| 244 | GlobalConfig.msType=1;//目前固定用这个 | 247 | GlobalConfig.msType=1;//目前固定用这个 |
| 245 | -GlobalConfig.mcuDelay=60;//默认的延迟时间 flash中使用的是3000毫秒 | ||
| 246 | -GlobalConfig.docDelay=1600;//文档模块加入成功之后延迟发送送成功的消息给主模块 | 248 | +GlobalConfig.messageDelay=false;//是否启用消息延迟 |
| 249 | +GlobalConfig.mcuDelay=0;//默认的延迟时间(单位-秒) | ||
| 250 | + | ||
| 251 | +GlobalConfig.docDelay=1600;//文档模块加入成功之后延迟发送送成功的消息给主模块(sdk内部使用) | ||
| 247 | GlobalConfig.portal="112.126.80.182:80";//Sass IP | 252 | GlobalConfig.portal="112.126.80.182:80";//Sass IP |
| 248 | 253 | ||
| 249 | //GlobalConfig.ip="112.126.80.182"; | 254 | //GlobalConfig.ip="112.126.80.182"; |
| @@ -305,6 +310,8 @@ GlobalConfig.recordFileName="";//录制的文件名,如 果为空就创建一个 | @@ -305,6 +310,8 @@ GlobalConfig.recordFileName="";//录制的文件名,如 果为空就创建一个 | ||
| 305 | GlobalConfig.recordDownloadUrl="";//下载地址 | 310 | GlobalConfig.recordDownloadUrl="";//下载地址 |
| 306 | GlobalConfig.recordReplaytickValues={}; // 滚动条关键点,用于快进快退 | 311 | GlobalConfig.recordReplaytickValues={}; // 滚动条关键点,用于快进快退 |
| 307 | 312 | ||
| 313 | +GlobalConfig.isAutoStartClass=0;//是否自动开始上课 0-否 ;1 是 | ||
| 314 | + | ||
| 308 | GlobalConfig.updateClassInfoDelay=30;//(秒),每隔30秒同步一次课堂状态的并保存到Sass | 315 | GlobalConfig.updateClassInfoDelay=30;//(秒),每隔30秒同步一次课堂状态的并保存到Sass |
| 309 | //GlobalConfig.serverTimestamp=0;//当前的系统时间戳 用get set 获取 | 316 | //GlobalConfig.serverTimestamp=0;//当前的系统时间戳 用get set 获取 |
| 310 | 317 | ||
| @@ -312,7 +319,10 @@ GlobalConfig.updateClassInfoDelay=30;//(秒),每隔30秒同步一次课堂状 | @@ -312,7 +319,10 @@ GlobalConfig.updateClassInfoDelay=30;//(秒),每隔30秒同步一次课堂状 | ||
| 312 | GlobalConfig.activeDocId=0;//当前激活的文档ID | 319 | GlobalConfig.activeDocId=0;//当前激活的文档ID |
| 313 | GlobalConfig.activeDocCurPage=1;//当前激活的文档的当前页 | 320 | GlobalConfig.activeDocCurPage=1;//当前激活的文档的当前页 |
| 314 | 321 | ||
| 315 | - | 322 | +//视频质量相关设置 |
| 323 | +GlobalConfig.fps=15;//帧频 | ||
| 324 | +GlobalConfig.gop=3;//关键帧间隔(秒) | ||
| 325 | +GlobalConfig.videoQuality=2;//画面质量 0-低;1-中;2-高; | ||
| 316 | 326 | ||
| 317 | 327 | ||
| 318 | GlobalConfig.classAllParam={};//Sass直接返回的所有课堂信息(最全) | 328 | GlobalConfig.classAllParam={};//Sass直接返回的所有课堂信息(最全) |
| @@ -293,6 +293,8 @@ class RecordPlayBackParse extends Emiter { | @@ -293,6 +293,8 @@ class RecordPlayBackParse extends Emiter { | ||
| 293 | position += byteLen; | 293 | position += byteLen; |
| 294 | 294 | ||
| 295 | this._parseSaveSocketMsgReceivedHandler(byteData, timestamp); | 295 | this._parseSaveSocketMsgReceivedHandler(byteData, timestamp); |
| 296 | + | ||
| 297 | + | ||
| 296 | //记录最后一个数据的时间戳作为整个录制回放的总时间戳 | 298 | //记录最后一个数据的时间戳作为整个录制回放的总时间戳 |
| 297 | this._recordPlaybackMaxTime = timestamp; | 299 | this._recordPlaybackMaxTime = timestamp; |
| 298 | } | 300 | } |
| @@ -300,6 +302,12 @@ class RecordPlayBackParse extends Emiter { | @@ -300,6 +302,12 @@ class RecordPlayBackParse extends Emiter { | ||
| 300 | this._isReady = true; | 302 | this._isReady = true; |
| 301 | this._stopTimerCounter(); | 303 | this._stopTimerCounter(); |
| 302 | 304 | ||
| 305 | + //录制回放的总时间长度按课堂最长时间计算,不能按最后一个消息的时间计算 | ||
| 306 | + if(this._recordPlaybackMaxTime<GlobalConfig.classTimestamp){ | ||
| 307 | + this._recordPlaybackMaxTime=GlobalConfig.classTimestamp; | ||
| 308 | + | ||
| 309 | + } | ||
| 310 | + | ||
| 303 | GlobalConfig.recordPlaybackMaxTime = this._recordPlaybackMaxTime; | 311 | GlobalConfig.recordPlaybackMaxTime = this._recordPlaybackMaxTime; |
| 304 | loger.log("录制回放数据解析完成,录制回放的总时间长为->", this._recordPlaybackMaxTime); | 312 | loger.log("录制回放数据解析完成,录制回放的总时间长为->", this._recordPlaybackMaxTime); |
| 305 | //console.log("_messages", this._messages); | 313 | //console.log("_messages", this._messages); |
| @@ -382,13 +390,13 @@ class RecordPlayBackParse extends Emiter { | @@ -382,13 +390,13 @@ class RecordPlayBackParse extends Emiter { | ||
| 382 | //查找关键帧,找到关键帧后再继续播放 | 390 | //查找关键帧,找到关键帧后再继续播放 |
| 383 | this._searchApeMessageKeyfram(this._conferApeMssages, ApeConsts.CONFERENCE_SESSION_ID); | 391 | this._searchApeMessageKeyfram(this._conferApeMssages, ApeConsts.CONFERENCE_SESSION_ID); |
| 384 | this._searchApeMessageKeyfram(this._docApeMssages, ApeConsts.DOCSHARING_SESSION_ID); | 392 | this._searchApeMessageKeyfram(this._docApeMssages, ApeConsts.DOCSHARING_SESSION_ID); |
| 385 | - this._searchApeMessageKeyfram(this._whiteApeMssages, ApeConsts.WHITEBOARD_SESSION_ID); | 393 | + //this._searchApeMessageKeyfram(this._whiteApeMssages, ApeConsts.WHITEBOARD_SESSION_ID); |
| 386 | this._searchApeMessageKeyfram(this._videoApeMssages, ApeConsts.VIDEO_SESSION_ID); | 394 | this._searchApeMessageKeyfram(this._videoApeMssages, ApeConsts.VIDEO_SESSION_ID); |
| 387 | this._searchApeMessageKeyfram(this._audioApeMssages, ApeConsts.AUDIO_SESSION_ID); | 395 | this._searchApeMessageKeyfram(this._audioApeMssages, ApeConsts.AUDIO_SESSION_ID); |
| 388 | 396 | ||
| 389 | - //聊天模块的比较特殊,消息是累计的 | ||
| 390 | - this._searchChatApeMessageKeyfram(this._chatApeMssages, ApeConsts.CHAT_SESSION_ID); | ||
| 391 | - | 397 | + //聊天模块、白板标注模块的比较特殊,消息是累计的,默认最多30条 |
| 398 | + this._searchApeHistoryMessageKeyfram(this._chatApeMssages, ApeConsts.CHAT_SESSION_ID); | ||
| 399 | + this._searchApeHistoryMessageKeyfram(this._whiteApeMssages, ApeConsts.WHITEBOARD_SESSION_ID); | ||
| 392 | 400 | ||
| 393 | //各个ape模块无论有没有找到关键帧数据,都继续播放 | 401 | //各个ape模块无论有没有找到关键帧数据,都继续播放 |
| 394 | this._startTimerCounter(); | 402 | this._startTimerCounter(); |
| @@ -420,7 +428,9 @@ class RecordPlayBackParse extends Emiter { | @@ -420,7 +428,9 @@ class RecordPlayBackParse extends Emiter { | ||
| 420 | } | 428 | } |
| 421 | 429 | ||
| 422 | //查找聊天模块ape关键帧数据,聊天模块比较特殊,消息是累积的,当前时间戳之前的都需要显示 | 430 | //查找聊天模块ape关键帧数据,聊天模块比较特殊,消息是累积的,当前时间戳之前的都需要显示 |
| 423 | - _searchChatApeMessageKeyfram(_apeMessages) { | 431 | + _searchApeHistoryMessageKeyfram(_apeMessages) { |
| 432 | + //最多30条数据 | ||
| 433 | + let counter=0; | ||
| 424 | let messageItem; | 434 | let messageItem; |
| 425 | let keyFrameSeek = 0; | 435 | let keyFrameSeek = 0; |
| 426 | for (let i = this._recordPlaybackTimestamp; i > 0; i--) { | 436 | for (let i = this._recordPlaybackTimestamp; i > 0; i--) { |
| @@ -429,9 +439,15 @@ class RecordPlayBackParse extends Emiter { | @@ -429,9 +439,15 @@ class RecordPlayBackParse extends Emiter { | ||
| 429 | //把时间点对应的数据发送,同一秒内有存在多个数据的情况 | 439 | //把时间点对应的数据发送,同一秒内有存在多个数据的情况 |
| 430 | for (let i = 0; i < messageItem.length; i++) { | 440 | for (let i = 0; i < messageItem.length; i++) { |
| 431 | this._everSocketMsgReceivedHandler(messageItem[i].byteData, 0); | 441 | this._everSocketMsgReceivedHandler(messageItem[i].byteData, 0); |
| 442 | + counter++; | ||
| 443 | + if(counter>30){ | ||
| 444 | + loger.warn("SEEK->最多处理历史消息30条"); | ||
| 445 | + return; | ||
| 446 | + } | ||
| 432 | } | 447 | } |
| 433 | } | 448 | } |
| 434 | } | 449 | } |
| 450 | + | ||
| 435 | } | 451 | } |
| 436 | 452 | ||
| 437 | } | 453 | } |
| @@ -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]; |
| @@ -316,6 +316,7 @@ class AudioApe extends Ape { | @@ -316,6 +316,7 @@ class AudioApe extends Ape { | ||
| 316 | let receiveChannelInfo={}; | 316 | let receiveChannelInfo={}; |
| 317 | receiveChannelInfo.mediaId=unpackChannelInfo.channelId; | 317 | receiveChannelInfo.mediaId=unpackChannelInfo.channelId; |
| 318 | receiveChannelInfo.fromNodeId=unpackChannelInfo.fromNodeId; | 318 | receiveChannelInfo.fromNodeId=unpackChannelInfo.fromNodeId; |
| 319 | + receiveChannelInfo.userName=unpackChannelInfo.userName||""; | ||
| 319 | 320 | ||
| 320 | //消息不是自己同步的,需要处理 | 321 | //消息不是自己同步的,需要处理 |
| 321 | if(unpackChannelInfo.status==ApeConsts.CHANNEL_STATUS_OPENING){ | 322 | if(unpackChannelInfo.status==ApeConsts.CHANNEL_STATUS_OPENING){ |
| @@ -375,6 +376,7 @@ class AudioApe extends Ape { | @@ -375,6 +376,7 @@ class AudioApe extends Ape { | ||
| 375 | packPduModel.mediaType =_param.mediaType|| ApeConsts.MEDIA_TYPE_AUDIO; | 376 | packPduModel.mediaType =_param.mediaType|| ApeConsts.MEDIA_TYPE_AUDIO; |
| 376 | packPduModel.timestamp =_param.timestamp||EngineUtils.creatTimestamp(); | 377 | packPduModel.timestamp =_param.timestamp||EngineUtils.creatTimestamp(); |
| 377 | packPduModel.fromNodeId = GlobalConfig.nodeId; | 378 | packPduModel.fromNodeId = GlobalConfig.nodeId; |
| 379 | + packPduModel.userName=GlobalConfig.userName||""; | ||
| 378 | packPduModel.toNodeId = 0; | 380 | packPduModel.toNodeId = 0; |
| 379 | loger.log("packPdu",packPduModel); | 381 | loger.log("packPdu",packPduModel); |
| 380 | return packPduModel; | 382 | return packPduModel; |
| @@ -377,6 +377,13 @@ class ConferApe extends Ape { | @@ -377,6 +377,13 @@ class ConferApe extends Ape { | ||
| 377 | 377 | ||
| 378 | //如果是host ,开始录制 | 378 | //如果是host ,开始录制 |
| 379 | this.startRecord(); | 379 | this.startRecord(); |
| 380 | + }else if(GlobalConfig.classStatus == ApeConsts.CLASS_STATUS_WAIT&& | ||
| 381 | + GlobalConfig.isHost&& GlobalConfig.isAutoStartClass&& | ||
| 382 | + !GlobalConfig.isRecordPlayBack){ | ||
| 383 | + //自动开始上课的4个条件 | ||
| 384 | + //1.如果自己是host,2.Sass配置的是自动开始上课,3.并且当前是未开始状态,4.当前不是录制回放,开始自动上课 | ||
| 385 | + loger.log('自动开始上课->classStatus:', GlobalConfig.classStatus, " isHost:",GlobalConfig.isHost, " isAutoStartClass:",GlobalConfig.isAutoStartClass, " isRecordPlayBack:",GlobalConfig.isRecordPlayBack); | ||
| 386 | + this.startClass(); | ||
| 380 | } | 387 | } |
| 381 | } | 388 | } |
| 382 | 389 |
| @@ -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); |
| @@ -243,7 +243,7 @@ class VideoApe extends Ape { | @@ -243,7 +243,7 @@ class VideoApe extends Ape { | ||
| 243 | } | 243 | } |
| 244 | return {"code": ApeConsts.RETURN_SUCCESS, "data": ""}; | 244 | return {"code": ApeConsts.RETURN_SUCCESS, "data": ""}; |
| 245 | } | 245 | } |
| 246 | - | 246 | + //发送到mcu同步(更新数据) |
| 247 | sendTableUpdateHandler(_channelInfo) { | 247 | sendTableUpdateHandler(_channelInfo) { |
| 248 | loger.log("video===sendTableUpdateHandler "); | 248 | loger.log("video===sendTableUpdateHandler "); |
| 249 | let updateModelPdu = this.packPdu(_channelInfo, _channelInfo.channelId);//let updateModelPdu=this.packPdu({},ApeConsts.VIDEO_OBJ_TABLE_ID+2); | 249 | let updateModelPdu = this.packPdu(_channelInfo, _channelInfo.channelId);//let updateModelPdu=this.packPdu({},ApeConsts.VIDEO_OBJ_TABLE_ID+2); |
| @@ -321,6 +321,7 @@ class VideoApe extends Ape { | @@ -321,6 +321,7 @@ class VideoApe extends Ape { | ||
| 321 | let receiveChannelInfo={}; | 321 | let receiveChannelInfo={}; |
| 322 | receiveChannelInfo.mediaId=unpackChannelInfo.channelId; | 322 | receiveChannelInfo.mediaId=unpackChannelInfo.channelId; |
| 323 | receiveChannelInfo.fromNodeId=unpackChannelInfo.fromNodeId; | 323 | receiveChannelInfo.fromNodeId=unpackChannelInfo.fromNodeId; |
| 324 | + receiveChannelInfo.userName=unpackChannelInfo.userName||""; | ||
| 324 | //消息不是自己同步的,需要处理 | 325 | //消息不是自己同步的,需要处理 |
| 325 | if(unpackChannelInfo.status==ApeConsts.CHANNEL_STATUS_OPENING){ | 326 | if(unpackChannelInfo.status==ApeConsts.CHANNEL_STATUS_OPENING){ |
| 326 | //正在推流 | 327 | //正在推流 |
| @@ -380,6 +381,7 @@ class VideoApe extends Ape { | @@ -380,6 +381,7 @@ class VideoApe extends Ape { | ||
| 380 | packPduModel.mediaType =_param.mediaType|| ApeConsts.MEDIA_TYPE_VIDEO; | 381 | packPduModel.mediaType =_param.mediaType|| ApeConsts.MEDIA_TYPE_VIDEO; |
| 381 | packPduModel.timestamp =_param.timestamp||0; | 382 | packPduModel.timestamp =_param.timestamp||0; |
| 382 | packPduModel.fromNodeId = GlobalConfig.nodeId; | 383 | packPduModel.fromNodeId = GlobalConfig.nodeId; |
| 384 | + packPduModel.userName=GlobalConfig.userName||""; | ||
| 383 | packPduModel.toNodeId = 0; | 385 | packPduModel.toNodeId = 0; |
| 384 | loger.log(packPduModel); | 386 | loger.log(packPduModel); |
| 385 | return packPduModel; | 387 | return packPduModel; |
| @@ -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; |
| @@ -777,6 +777,7 @@ message RCAudioChannelInfoPdu { | @@ -777,6 +777,7 @@ message RCAudioChannelInfoPdu { | ||
| 777 | optional string site_id = 8;//站点号 | 777 | optional string site_id = 8;//站点号 |
| 778 | optional string user_id = 9;//用户的userId | 778 | optional string user_id = 9;//用户的userId |
| 779 | optional string stream_id = 10;//流名称 | 779 | optional string stream_id = 10;//流名称 |
| 780 | + optional string user_name = 11;//用户的名字 | ||
| 780 | } | 781 | } |
| 781 | 782 | ||
| 782 | message RCVideoChannelInfoPdu { | 783 | message RCVideoChannelInfoPdu { |
| @@ -790,6 +791,7 @@ message RCVideoChannelInfoPdu { | @@ -790,6 +791,7 @@ message RCVideoChannelInfoPdu { | ||
| 790 | optional string site_id = 8;//站点号 | 791 | optional string site_id = 8;//站点号 |
| 791 | optional string user_id = 9;//用户的userId | 792 | optional string user_id = 9;//用户的userId |
| 792 | optional string stream_id = 10;//流名称 | 793 | optional string stream_id = 10;//流名称 |
| 794 | + optional string user_name = 11;//用户的名字 | ||
| 793 | } | 795 | } |
| 794 | 796 | ||
| 795 | message RCVideoChannelInfoRecordPdu { | 797 | message RCVideoChannelInfoRecordPdu { |
-
请 注册 或 登录 后发表评论