正在显示
7 个修改的文件
包含
231 行增加
和
2 行删除
此 diff 太大无法显示。
| @@ -26,7 +26,7 @@ | @@ -26,7 +26,7 @@ | ||
| 26 | "spec": ">=2.0.0 <3.0.0", | 26 | "spec": ">=2.0.0 <3.0.0", |
| 27 | "type": "range" | 27 | "type": "range" |
| 28 | }, | 28 | }, |
| 29 | - "_requiredBy": [ | 29 | + "_//this._emitdBy": [ |
| 30 | "/strip-ansi" | 30 | "/strip-ansi" |
| 31 | ], | 31 | ], |
| 32 | "_resolved": "http://registry.npm.taobao.org/ansi-regex/download/ansi-regex-2.0.0.tgz", | 32 | "_resolved": "http://registry.npm.taobao.org/ansi-regex/download/ansi-regex-2.0.0.tgz", |
| @@ -17,6 +17,7 @@ import VideoApe from 'apes/VideoApe'; | @@ -17,6 +17,7 @@ import VideoApe from 'apes/VideoApe'; | ||
| 17 | import AudioApe from 'apes/AudioApe'; | 17 | import AudioApe from 'apes/AudioApe'; |
| 18 | import DocApe from 'apes/DocApe'; | 18 | import DocApe from 'apes/DocApe'; |
| 19 | import WhiteBoardApe from 'apes/WhiteBoardApe'; | 19 | import WhiteBoardApe from 'apes/WhiteBoardApe'; |
| 20 | +import ThirdMessage from 'apes/ThirdMessage'; | ||
| 20 | import EngineUtils from "EngineUtils"; | 21 | import EngineUtils from "EngineUtils"; |
| 21 | import GlobalConfig from 'GlobalConfig'; | 22 | import GlobalConfig from 'GlobalConfig'; |
| 22 | import ApeConsts from 'apes/ApeConsts'; | 23 | import ApeConsts from 'apes/ApeConsts'; |
| @@ -28,7 +29,7 @@ import MediaModule from 'apes/MediaModule'; | @@ -28,7 +29,7 @@ import MediaModule from 'apes/MediaModule'; | ||
| 28 | import UTF8 from 'utf-8'; | 29 | import UTF8 from 'utf-8'; |
| 29 | 30 | ||
| 30 | let loger = Loger.getLoger('McuClient'); | 31 | let loger = Loger.getLoger('McuClient'); |
| 31 | -let _sdkInfo = {"version": "v1.28.0.201705031", "author": "www.3mang.com"}; | 32 | +let _sdkInfo = {"version": "v1.29.1.20170601", "author": "www.3mang.com"}; |
| 32 | 33 | ||
| 33 | //APE | 34 | //APE |
| 34 | let _sass; | 35 | let _sass; |
| @@ -41,6 +42,7 @@ let _audio_ape; | @@ -41,6 +42,7 @@ let _audio_ape; | ||
| 41 | let _doc_ape; | 42 | let _doc_ape; |
| 42 | let _whiteboard_ape; | 43 | let _whiteboard_ape; |
| 43 | let _recordPlayback; | 44 | let _recordPlayback; |
| 45 | +let _thirdMessage; | ||
| 44 | 46 | ||
| 45 | //MCUClient 外部实例化主类 | 47 | //MCUClient 外部实例化主类 |
| 46 | export default class MessageEntrance extends Emiter { | 48 | export default class MessageEntrance extends Emiter { |
| @@ -60,6 +62,9 @@ export default class MessageEntrance extends Emiter { | @@ -60,6 +62,9 @@ export default class MessageEntrance extends Emiter { | ||
| 60 | //全局的Error处理 | 62 | //全局的Error处理 |
| 61 | this.on(MessageTypes.MCU_ERROR, this._mcuErrorHandler.bind(this)); | 63 | this.on(MessageTypes.MCU_ERROR, this._mcuErrorHandler.bind(this)); |
| 62 | 64 | ||
| 65 | + // | ||
| 66 | + _thirdMessage=new ThirdMessage(); | ||
| 67 | + | ||
| 63 | // Sass平台层 | 68 | // Sass平台层 |
| 64 | _sass = Sass; | 69 | _sass = Sass; |
| 65 | _sass.on('*', (type, data) => this._emit(type, data)); | 70 | _sass.on('*', (type, data) => this._emit(type, data)); |
| @@ -45,6 +45,7 @@ class ConferApe extends Ape { | @@ -45,6 +45,7 @@ class ConferApe extends Ape { | ||
| 45 | 45 | ||
| 46 | this.on(pdu.RCPDU_SEND_CONFERENCE_DATA_REQUEST, this.conferMsgComingHandler.bind(this));//这个是课堂消息类型,flash里在使用这里不再使用,各个模块的消息由模块自己来处理 | 46 | this.on(pdu.RCPDU_SEND_CONFERENCE_DATA_REQUEST, this.conferMsgComingHandler.bind(this));//这个是课堂消息类型,flash里在使用这里不再使用,各个模块的消息由模块自己来处理 |
| 47 | this.on(pdu.RCPDU_CONFERENCE_RECORD_REQUEST, this.onSendConferRecordRequestHandler.bind(this));//发送录制和停止录制消息 | 47 | this.on(pdu.RCPDU_CONFERENCE_RECORD_REQUEST, this.onSendConferRecordRequestHandler.bind(this));//发送录制和停止录制消息 |
| 48 | + this.on(pdu.RCPDU_THIRD_BROADCAST_DATA_REQUEST, this.onThirdBroadcastDataHandler.bind(this));//第三方广播消息 | ||
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | //加入课堂 | 51 | //加入课堂 |
| @@ -633,6 +634,49 @@ class ConferApe extends Ape { | @@ -633,6 +634,49 @@ class ConferApe extends Ape { | ||
| 633 | } | 634 | } |
| 634 | } | 635 | } |
| 635 | 636 | ||
| 637 | + //-------------第三方消息------------------------------ | ||
| 638 | + //发送第三方广播消息 | ||
| 639 | + sendThirdBroadcastData(_param){ | ||
| 640 | + loger.log("发送第三方广播消息->",_param); | ||
| 641 | + if (this._classInfo == null || EngineUtils.isEmptyObject(this._classInfo)) { | ||
| 642 | + loger.log('发送第三方广播消息->失败->SDK还未初始化数据!'); | ||
| 643 | + if (GlobalConfig.getCurrentStatus().code == 0 || GlobalConfig.getCurrentStatus().code == 1) { | ||
| 644 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_APE_SEND_FAILED_NO_JOIN); | ||
| 645 | + return; | ||
| 646 | + } | ||
| 647 | + return; | ||
| 648 | + } | ||
| 649 | + | ||
| 650 | + let thirdBroadcastSendPdu = new pdu['RCThirdSendBroadcastDataRequestPdu']; | ||
| 651 | + thirdBroadcastSendPdu.type = pdu.RCPDU_THIRD_BROADCAST_DATA_REQUEST; | ||
| 652 | + thirdBroadcastSendPdu.initiator = this._classInfo.nodeId;//发起人 | ||
| 653 | + thirdBroadcastSendPdu.peer = parseInt(_param.to);//发送给谁,公聊的时候是0,私聊的时候是指定的用户id | ||
| 654 | + thirdBroadcastSendPdu.isPublic = true; | ||
| 655 | + thirdBroadcastSendPdu.message = this._rCArrayBufferUtil.strToUint8Array("h5" + _param.message); | ||
| 656 | + | ||
| 657 | + if (!thirdBroadcastSendPdu.isPublic && 0 != thirdBroadcastSendPdu.peer) { | ||
| 658 | + //发送给制定的人 | ||
| 659 | + this.send(thirdBroadcastSendPdu); | ||
| 660 | + } else { | ||
| 661 | + //发送给所有人 | ||
| 662 | + this.sendChatUniform(thirdBroadcastSendPdu); | ||
| 663 | + } | ||
| 664 | + } | ||
| 665 | + | ||
| 666 | + | ||
| 667 | + //监听第三方消息通道消息 | ||
| 668 | + onThirdBroadcastDataHandler(_data){ | ||
| 669 | + //loger.log("监听第三方消息通道消息->",_data); | ||
| 670 | + var thirdBroadcastReceivePdu = pdu['RCThirdSendBroadcastDataRequestPdu'].decode(_data); | ||
| 671 | + var thirdMessage = {}; | ||
| 672 | + thirdMessage.fromNodeID = thirdBroadcastReceivePdu.initiator; | ||
| 673 | + thirdMessage.toNodeID = thirdBroadcastReceivePdu.peer; | ||
| 674 | + thirdMessage.message = this._rCArrayBufferUtil.uint8ArrayToStr(thirdBroadcastReceivePdu.userData, 2); | ||
| 675 | + loger.log("监听第三方消息通道消息->", thirdMessage); | ||
| 676 | + } | ||
| 677 | + | ||
| 678 | + //------------------第三方消息 end----------------------------------------- | ||
| 679 | + | ||
| 636 | onSendConferRecordRequestHandler(_data) { | 680 | onSendConferRecordRequestHandler(_data) { |
| 637 | try { | 681 | try { |
| 638 | let conferRecordSendPdu = pdu['RCConferenceRecordRequestPdu'].decode(_data); | 682 | let conferRecordSendPdu = pdu['RCConferenceRecordRequestPdu'].decode(_data); |
src/apes/ThirdMessage.js
0 → 100644
| 1 | +require('messenger'); | ||
| 2 | +import Emiter from 'Emiter'; | ||
| 3 | +import McuObj from 'mcu'; | ||
| 4 | +import Loger from 'Loger'; | ||
| 5 | +let loger = Loger.getLoger('ThirdMessage'); | ||
| 6 | +class ThirdMessage extends Emiter{ | ||
| 7 | + constructor(){ | ||
| 8 | + super(); | ||
| 9 | + // 初始化消息通道 | ||
| 10 | + this.messenger = new Messenger('xuedianyunIframe', 'ParentMessengerChannel'); | ||
| 11 | + this.messenger.addTarget(window.parent, 'parent'); | ||
| 12 | + this.messenger.listen(this.reciveThirdMessage.bind(this)) | ||
| 13 | + loger.log('ThirdMessage->'); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + //发送消息 | ||
| 17 | + sendMessage(){ | ||
| 18 | + // 根据自己的业务组装对象 | ||
| 19 | + let jsonObj = { | ||
| 20 | + username: 'sdk', | ||
| 21 | + message: 'sdk->hello world', | ||
| 22 | + } | ||
| 23 | + this.messenger.send(JSON.stringify(jsonObj)); | ||
| 24 | + } | ||
| 25 | + reciveThirdMessage(_data){ | ||
| 26 | + loger.log('来自父级页面的的消息:', _data); | ||
| 27 | + // **发送前必须转JSON格式** | ||
| 28 | + this.sendMessage(); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | +} | ||
| 32 | +export default ThirdMessage; |
src/messenger.js
0 → 100644
| 1 | +/** | ||
| 2 | + * __ ___ | ||
| 3 | + * / |/ /___ _____ _____ ___ ____ ____ _ ___ _____ | ||
| 4 | + * / /|_/ // _ \ / ___// ___// _ \ / __ \ / __ `// _ \ / ___/ | ||
| 5 | + * / / / // __/(__ )(__ )/ __// / / // /_/ // __// / | ||
| 6 | + * /_/ /_/ \___//____//____/ \___//_/ /_/ \__, / \___//_/ | ||
| 7 | + * /____/ | ||
| 8 | + * | ||
| 9 | + * @description MessengerJS, a common cross-document communicate solution. | ||
| 10 | + * @author biqing kwok | ||
| 11 | + * @version 2.0 | ||
| 12 | + * @license release under MIT license | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | +window.Messenger = (function () { | ||
| 16 | + | ||
| 17 | + // 消息前缀, 建议使用自己的项目名, 避免多项目之间的冲突 | ||
| 18 | + // !注意 消息前缀应使用字符串类型 | ||
| 19 | + var prefix = "[PROJECT_NAME]", | ||
| 20 | + supportPostMessage = 'postMessage' in window; | ||
| 21 | + | ||
| 22 | + // Target 类, 消息对象 | ||
| 23 | + function Target(target, name, prefix) { | ||
| 24 | + var errMsg = ''; | ||
| 25 | + if (arguments.length < 2) { | ||
| 26 | + errMsg = 'target error - target and name are both required'; | ||
| 27 | + } else if (typeof target != 'object') { | ||
| 28 | + errMsg = 'target error - target itself must be window object'; | ||
| 29 | + } else if (typeof name != 'string') { | ||
| 30 | + errMsg = 'target error - target name must be string type'; | ||
| 31 | + } | ||
| 32 | + if (errMsg) { | ||
| 33 | + throw new Error(errMsg); | ||
| 34 | + } | ||
| 35 | + this.target = target; | ||
| 36 | + this.name = name; | ||
| 37 | + this.prefix = prefix; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + // 往 target 发送消息, 出于安全考虑, 发送消息会带上前缀 | ||
| 41 | + if (supportPostMessage) { | ||
| 42 | + // IE8+ 以及现代浏览器支持 | ||
| 43 | + Target.prototype.send = function (msg) { | ||
| 44 | + this.target.postMessage(this.prefix + '|' + this.name + '__Messenger__' + msg, '*'); | ||
| 45 | + }; | ||
| 46 | + } else { | ||
| 47 | + // 兼容IE 6/7 | ||
| 48 | + Target.prototype.send = function (msg) { | ||
| 49 | + var targetFunc = window.navigator[this.prefix + this.name]; | ||
| 50 | + if (typeof targetFunc == 'function') { | ||
| 51 | + targetFunc(this.prefix + msg, window); | ||
| 52 | + } else { | ||
| 53 | + throw new Error("target callback function is not defined"); | ||
| 54 | + } | ||
| 55 | + }; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + // 信使类 | ||
| 59 | + // 创建Messenger实例时指定, 必须指定Messenger的名字, (可选)指定项目名, 以避免Mashup类应用中的冲突 | ||
| 60 | + // !注意: 父子页面中projectName必须保持一致, 否则无法匹配 | ||
| 61 | + function Messenger(messengerName, projectName) { | ||
| 62 | + this.targets = {}; | ||
| 63 | + this.name = messengerName; | ||
| 64 | + this.listenFunc = []; | ||
| 65 | + this.prefix = projectName || prefix; | ||
| 66 | + this.initListen(); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + // 添加一个消息对象 | ||
| 70 | + Messenger.prototype.addTarget = function (target, name) { | ||
| 71 | + var targetObj = new Target(target, name, this.prefix); | ||
| 72 | + this.targets[name] = targetObj; | ||
| 73 | + }; | ||
| 74 | + | ||
| 75 | + // 初始化消息监听 | ||
| 76 | + Messenger.prototype.initListen = function () { | ||
| 77 | + var self = this; | ||
| 78 | + var generalCallback = function (msg) { | ||
| 79 | + debugger; | ||
| 80 | + if (typeof msg == 'object' && msg.data) { | ||
| 81 | + msg = msg.data; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + var msgPairs = msg.split('__Messenger__'); | ||
| 85 | + var msg = msgPairs[1]; | ||
| 86 | + var pairs = msgPairs[0].split('|'); | ||
| 87 | + var prefix = pairs[0]; | ||
| 88 | + var name = pairs[1]; | ||
| 89 | + | ||
| 90 | + for (var i = 0; i < self.listenFunc.length; i++) { | ||
| 91 | + if (prefix + name === self.prefix + self.name) { | ||
| 92 | + self.listenFunc[i](msg); | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + }; | ||
| 96 | + | ||
| 97 | + if (supportPostMessage) { | ||
| 98 | + if ('addEventListener' in document) { | ||
| 99 | + window.addEventListener('message', generalCallback, false); | ||
| 100 | + } else if ('attachEvent' in document) { | ||
| 101 | + window.attachEvent('onmessage', generalCallback); | ||
| 102 | + } | ||
| 103 | + } else { | ||
| 104 | + // 兼容IE 6/7 | ||
| 105 | + window.navigator[this.prefix + this.name] = generalCallback; | ||
| 106 | + } | ||
| 107 | + }; | ||
| 108 | + | ||
| 109 | + // 监听消息 | ||
| 110 | + Messenger.prototype.listen = function (callback) { | ||
| 111 | + var i = 0; | ||
| 112 | + var len = this.listenFunc.length; | ||
| 113 | + var cbIsExist = false; | ||
| 114 | + for (; i < len; i++) { | ||
| 115 | + if (this.listenFunc[i] == callback) { | ||
| 116 | + cbIsExist = true; | ||
| 117 | + break; | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + if (!cbIsExist) { | ||
| 121 | + this.listenFunc.push(callback); | ||
| 122 | + } | ||
| 123 | + }; | ||
| 124 | + // 注销监听 | ||
| 125 | + Messenger.prototype.clear = function () { | ||
| 126 | + this.listenFunc = []; | ||
| 127 | + }; | ||
| 128 | + // 广播消息 | ||
| 129 | + Messenger.prototype.send = function (msg) { | ||
| 130 | + var targets = this.targets, | ||
| 131 | + target; | ||
| 132 | + for (target in targets) { | ||
| 133 | + if (targets.hasOwnProperty(target)) { | ||
| 134 | + targets[target].send(msg); | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | + }; | ||
| 138 | + | ||
| 139 | + return Messenger; | ||
| 140 | +})(); | ||
| 141 | + |
| @@ -704,6 +704,13 @@ message RCConferenceSendDataRequestPdu { | @@ -704,6 +704,13 @@ message RCConferenceSendDataRequestPdu { | ||
| 704 | optional uint32 action_type = 5;//消息的指令类型 | 704 | optional uint32 action_type = 5;//消息的指令类型 |
| 705 | } | 705 | } |
| 706 | 706 | ||
| 707 | +message RCThirdSendBroadcastDataRequestPdu { | ||
| 708 | + optional uint32 initiator = 1; | ||
| 709 | + optional uint32 peer = 2; | ||
| 710 | + optional bool is_public = 3; | ||
| 711 | + optional bytes message = 4; | ||
| 712 | +} | ||
| 713 | + | ||
| 707 | message RCChatSendDataRequestPdu { | 714 | message RCChatSendDataRequestPdu { |
| 708 | optional uint32 initiator = 1; | 715 | optional uint32 initiator = 1; |
| 709 | optional uint32 peer = 2; | 716 | optional uint32 peer = 2; |
-
请 注册 或 登录 后发表评论