修改server.json获取规则,Sass返回的结构和本地server.json结构统一,Sass返回一个新的字段,之前的mcuList和msList不再使用
正在显示
7 个修改的文件
包含
3394 行增加
和
184 行删除
| @@ -27,7 +27,7 @@ import SystemConfig from 'SystemConfig'; | @@ -27,7 +27,7 @@ import SystemConfig from 'SystemConfig'; | ||
| 27 | import ApeConsts from 'apes/ApeConsts'; | 27 | import ApeConsts from 'apes/ApeConsts'; |
| 28 | import Base64 from 'base64-js'; | 28 | import Base64 from 'base64-js'; |
| 29 | import ArrayBufferUtil from 'libs/ArrayBufferUtil'; | 29 | import ArrayBufferUtil from 'libs/ArrayBufferUtil'; |
| 30 | -import Server from "config/Server"; | 30 | +import ServerConfig from "config/ServerConfig"; |
| 31 | import MediaModule from 'apes/MediaModule'; | 31 | import MediaModule from 'apes/MediaModule'; |
| 32 | import MediaSharedApe from 'apes/MediaSharedApe'; | 32 | import MediaSharedApe from 'apes/MediaSharedApe'; |
| 33 | import MusicSharedApe from 'apes/MusicSharedApe'; | 33 | import MusicSharedApe from 'apes/MusicSharedApe'; |
| @@ -35,7 +35,7 @@ import QuestionApe from 'apes/QuestionApe'; | @@ -35,7 +35,7 @@ import QuestionApe from 'apes/QuestionApe'; | ||
| 35 | import UTF8 from 'utf-8'; | 35 | import UTF8 from 'utf-8'; |
| 36 | 36 | ||
| 37 | let loger = Loger.getLoger('McuClient'); | 37 | let loger = Loger.getLoger('McuClient'); |
| 38 | -let _sdkInfo = {"version": "v1.54.2.20170727", "author": "www.3mang.com"}; | 38 | +let _sdkInfo = {"version": "v1.55.6.20170727", "author": "www.3mang.com"}; |
| 39 | 39 | ||
| 40 | //APE | 40 | //APE |
| 41 | let _sass; | 41 | let _sass; |
| @@ -114,8 +114,8 @@ export default class MessageEntrance extends Emiter { | @@ -114,8 +114,8 @@ export default class MessageEntrance extends Emiter { | ||
| 114 | _confer_ape.on(MessageTypes.CLASS_RECORD_START, this._onClassRecordStart.bind(this)); //课堂开始录制 | 114 | _confer_ape.on(MessageTypes.CLASS_RECORD_START, this._onClassRecordStart.bind(this)); //课堂开始录制 |
| 115 | _confer_ape.on(MessageTypes.CLASS_RECORD_SUCCESS, this._onClassRecordSuccess.bind(this)); //课堂开启录制成功 | 115 | _confer_ape.on(MessageTypes.CLASS_RECORD_SUCCESS, this._onClassRecordSuccess.bind(this)); //课堂开启录制成功 |
| 116 | _confer_ape.on(MessageTypes.SWITCH_MS_IP, this._switchMsIpHandler.bind(this)); //MS动态选点 | 116 | _confer_ape.on(MessageTypes.SWITCH_MS_IP, this._switchMsIpHandler.bind(this)); //MS动态选点 |
| 117 | - _confer_ape.on(MessageTypes.SWITCH_RTMP_PULL_IP, this._switchRtmpPullIpHandler.bind(this)); //MS 拉流地址动态选点 | ||
| 118 | - _confer_ape.on(MessageTypes.SWITCH_HLS_IP, this._switchHlsIpHandler.bind(this)); //MS HLS动态选点 | 117 | + //_confer_ape.on(MessageTypes.SWITCH_RTMP_PULL_IP, this._switchRtmpPullIpHandler.bind(this)); //MS 拉流地址动态选点 |
| 118 | + //_confer_ape.on(MessageTypes.SWITCH_HLS_IP, this._switchHlsIpHandler.bind(this)); //MS HLS动态选点 | ||
| 119 | _confer_ape.on(MessageTypes.STOP_ALL_MEDIA_PUBLISH, this._stopAllMediaPublishHandler.bind(this)); //课堂状态发生改变,需要停止当前的所有推流 | 119 | _confer_ape.on(MessageTypes.STOP_ALL_MEDIA_PUBLISH, this._stopAllMediaPublishHandler.bind(this)); //课堂状态发生改变,需要停止当前的所有推流 |
| 120 | 120 | ||
| 121 | _chat_ape = new ChatApe(); | 121 | _chat_ape = new ChatApe(); |
| @@ -565,7 +565,19 @@ export default class MessageEntrance extends Emiter { | @@ -565,7 +565,19 @@ export default class MessageEntrance extends Emiter { | ||
| 565 | let _this = this; | 565 | let _this = this; |
| 566 | if (_ipManager) { | 566 | if (_ipManager) { |
| 567 | //先加载本地Server.json文件,然后获取userIp新 | 567 | //先加载本地Server.json文件,然后获取userIp新 |
| 568 | - _ipManager.loadServerJosn(function (_data) { | 568 | + _ipManager.loadServerJosn(function (_callbackData) { |
| 569 | + //本地Server.json加载后需要判断是否有数据,如果没有数据就用Sass的 | ||
| 570 | + //_callbackData.data=ret; | ||
| 571 | + //_callbackData.ret=1; | ||
| 572 | + ServerConfig.localServerJson=_callbackData.data; | ||
| 573 | + console.warn("本地SERVER数据",_callbackData); | ||
| 574 | + if(!ServerConfig.localServerJson||!ServerConfig.localServerJson.MCU||!ServerConfig.localServerJson.MS){ | ||
| 575 | + ServerConfig.serverList=ServerConfig.sassServerJson;//本地JSON数据加载完数据无效,使用Sass的 | ||
| 576 | + loger.warn("使用从Sass获取的server"); | ||
| 577 | + }else { | ||
| 578 | + ServerConfig.serverList=ServerConfig.localServerJson; | ||
| 579 | + loger.warn("使用从本地获取的server"); | ||
| 580 | + } | ||
| 569 | _ipManager.getUserIpInfo("", GlobalConfig.userIp, _this._getUserIpCallbackHandler.bind(_this), 2000); | 581 | _ipManager.getUserIpInfo("", GlobalConfig.userIp, _this._getUserIpCallbackHandler.bind(_this), 2000); |
| 570 | }) | 582 | }) |
| 571 | } | 583 | } |
| @@ -584,15 +596,18 @@ export default class MessageEntrance extends Emiter { | @@ -584,15 +596,18 @@ export default class MessageEntrance extends Emiter { | ||
| 584 | GlobalConfig.province = _data.province; //服务商 | 596 | GlobalConfig.province = _data.province; //服务商 |
| 585 | GlobalConfig.isp = _data.isp; //服务商 | 597 | GlobalConfig.isp = _data.isp; //服务商 |
| 586 | } | 598 | } |
| 587 | - | ||
| 588 | //根据用户的userIp信息从sever.json和Sass中选择最终mcu和推流拉流数据列表 | 599 | //根据用户的userIp信息从sever.json和Sass中选择最终mcu和推流拉流数据列表 |
| 589 | - this._choiceMcuAndMsListFromServerAndSass(); | 600 | + this._choiceMcuAndMsListFromServer(); |
| 601 | + //获取MCU和MS 推流拉流、录制回放的默认地址 | ||
| 602 | + this.getMcuAndMsDefaultServerIp(); | ||
| 603 | + loger.warn("加入课堂之前->开始测速->选择默认服务"); | ||
| 604 | + this._startFirstTestBestServer(); | ||
| 605 | + } | ||
| 590 | 606 | ||
| 591 | - loger.warn("加入课堂之前->开始测速选择默认服务"); | 607 | + //开始加入课堂前第一次测速 |
| 608 | + _startFirstTestBestServer(){ | ||
| 592 | //加入课堂之前开始第一次选点 | 609 | //加入课堂之前开始第一次选点 |
| 593 | let _this = this; | 610 | let _this = this; |
| 594 | - | ||
| 595 | - | ||
| 596 | //推流地址测速 | 611 | //推流地址测速 |
| 597 | this._getFastestIpFromServer(GlobalConfig.msListFinal, | 612 | this._getFastestIpFromServer(GlobalConfig.msListFinal, |
| 598 | function (_data) { | 613 | function (_data) { |
| @@ -606,7 +621,7 @@ export default class MessageEntrance extends Emiter { | @@ -606,7 +621,7 @@ export default class MessageEntrance extends Emiter { | ||
| 606 | }); | 621 | }); |
| 607 | 622 | ||
| 608 | //录制回放HLS拉流地址测速 | 623 | //录制回放HLS拉流地址测速 |
| 609 | - this._getFastestIpFromServer(GlobalConfig.rsListFinal, function (_data) { | 624 | + this._getFastestIpFromServer(GlobalConfig.rsPullListFinal, function (_data) { |
| 610 | loger.log("录制回放HLS拉流地址测速->", _data); | 625 | loger.log("录制回放HLS拉流地址测速->", _data); |
| 611 | if (_data && _data.ip) { | 626 | if (_data && _data.ip) { |
| 612 | GlobalConfig.RS_RECORD_PLAY_IP = _data.ip || ""; | 627 | GlobalConfig.RS_RECORD_PLAY_IP = _data.ip || ""; |
| @@ -628,7 +643,7 @@ export default class MessageEntrance extends Emiter { | @@ -628,7 +643,7 @@ export default class MessageEntrance extends Emiter { | ||
| 628 | }); | 643 | }); |
| 629 | 644 | ||
| 630 | //HLS拉流地址测速 | 645 | //HLS拉流地址测速 |
| 631 | - this._getFastestIpFromServer(GlobalConfig.hlsListFinal, function (_data) { | 646 | + this._getFastestIpFromServer(GlobalConfig.hlsPullListFinal, function (_data) { |
| 632 | loger.log("HLS拉流地址测速->", _data); | 647 | loger.log("HLS拉流地址测速->", _data); |
| 633 | if (_data && _data.ip) { | 648 | if (_data && _data.ip) { |
| 634 | GlobalConfig.MS_PLAY_HLS_IP = _data.ip || ""; | 649 | GlobalConfig.MS_PLAY_HLS_IP = _data.ip || ""; |
| @@ -650,58 +665,6 @@ export default class MessageEntrance extends Emiter { | @@ -650,58 +665,6 @@ export default class MessageEntrance extends Emiter { | ||
| 650 | }); | 665 | }); |
| 651 | } | 666 | } |
| 652 | 667 | ||
| 653 | - | ||
| 654 | - /* //本地JOSN加载完成-获取IP信息完成 | ||
| 655 | - _getUserIpCallbackHandler(_data) { | ||
| 656 | - //获取IP信息,返回一次就不再处理 | ||
| 657 | - if (this.isGetUserIpCallback) { | ||
| 658 | - return; | ||
| 659 | - } | ||
| 660 | - this.isGetUserIpCallback = true; | ||
| 661 | - if (_data && _data.ret == "ok") { | ||
| 662 | - GlobalConfig.country = _data.country; //国家 | ||
| 663 | - GlobalConfig.city = _data.city; //城市 | ||
| 664 | - GlobalConfig.province = _data.province; //服务商 | ||
| 665 | - GlobalConfig.isp = _data.isp; //服务商 | ||
| 666 | - } | ||
| 667 | - | ||
| 668 | - //合并MCU 、MS的列表 | ||
| 669 | - this._choiceMcuAndMsList(); | ||
| 670 | - | ||
| 671 | - //开始选点 | ||
| 672 | - let _this = this; | ||
| 673 | - | ||
| 674 | - //有一些站点不需要进行MS选点,需要先检查一下 | ||
| 675 | - if (GlobalConfig.siteId_letv == GlobalConfig.siteId) { | ||
| 676 | - //MS不需要选点 | ||
| 677 | - loger.log("MS不需要选点->siteId->", GlobalConfig.siteId); | ||
| 678 | - _this.isGetFastestMcuCallback = true; | ||
| 679 | - _this._startConnectMCU(); | ||
| 680 | - } else { | ||
| 681 | - this._getFastestMsServer(function (_data) { | ||
| 682 | - loger.log("MS选点结束->", _data); | ||
| 683 | - if (_data && _data.ip) { | ||
| 684 | - GlobalConfig.MS_PUBLISH_IP = _data.ip || ""; | ||
| 685 | - GlobalConfig.MS_PUBLISH_PORT = _data.port || ""; | ||
| 686 | - } | ||
| 687 | - loger.log("当前使用的MS->", GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT); | ||
| 688 | - _this.isGetFastestMcuCallback = true; | ||
| 689 | - _this._startConnectMCU(); | ||
| 690 | - }); | ||
| 691 | - } | ||
| 692 | - | ||
| 693 | - this._getFastestMcuServer(function (_data) { | ||
| 694 | - loger.log("MCU选点结束->", _data); | ||
| 695 | - if (_data && _data.ip) { | ||
| 696 | - GlobalConfig.MCUServerIP = _data.ip || ""; | ||
| 697 | - GlobalConfig.MCUServerPort = _data.port || ""; | ||
| 698 | - } | ||
| 699 | - loger.log("当前使用的MCU->", GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); | ||
| 700 | - _this.isGetFastestMsCallback = true; | ||
| 701 | - _this._startConnectMCU(); | ||
| 702 | - }); | ||
| 703 | - }*/ | ||
| 704 | - | ||
| 705 | //开始连接MCU(所有服务地址测试完成之后开始连接) | 668 | //开始连接MCU(所有服务地址测试完成之后开始连接) |
| 706 | _startConnectMCU() { | 669 | _startConnectMCU() { |
| 707 | if (this.isGetFastestMcuCallback && | 670 | if (this.isGetFastestMcuCallback && |
| @@ -718,103 +681,113 @@ export default class MessageEntrance extends Emiter { | @@ -718,103 +681,113 @@ export default class MessageEntrance extends Emiter { | ||
| 718 | } | 681 | } |
| 719 | } | 682 | } |
| 720 | 683 | ||
| 721 | - //从Sever和Sass中选择的mcu、ms列表,如果server.json中存在就不使用Sass | ||
| 722 | - _choiceMcuAndMsListFromServerAndSass() { | 684 | + //从Sever中选择的mcu、ms列表,如果server.json中存在就不使用Sass |
| 685 | + _choiceMcuAndMsListFromServer() { | ||
| 723 | //1.根据user信息获取服务器列表 | 686 | //1.根据user信息获取服务器列表 |
| 724 | if (_ipManager) { | 687 | if (_ipManager) { |
| 725 | - GlobalConfig.mcuListFromServer = _ipManager.getServerListForUserInfo( | 688 | + GlobalConfig.mcuListFinal = _ipManager.getServerListForUserInfo( |
| 726 | "MCU", | 689 | "MCU", |
| 727 | GlobalConfig.country, | 690 | GlobalConfig.country, |
| 728 | GlobalConfig.province, | 691 | GlobalConfig.province, |
| 729 | GlobalConfig.city, | 692 | GlobalConfig.city, |
| 730 | GlobalConfig.isp, | 693 | GlobalConfig.isp, |
| 731 | - Server.serverList); | 694 | + ServerConfig.serverList); |
| 732 | 695 | ||
| 733 | - GlobalConfig.msListFromServer = _ipManager.getServerListForUserInfo( | 696 | + GlobalConfig.msListFinal = _ipManager.getServerListForUserInfo( |
| 734 | "MS", | 697 | "MS", |
| 735 | GlobalConfig.country, | 698 | GlobalConfig.country, |
| 736 | GlobalConfig.province, | 699 | GlobalConfig.province, |
| 737 | GlobalConfig.city, | 700 | GlobalConfig.city, |
| 738 | GlobalConfig.isp, | 701 | GlobalConfig.isp, |
| 739 | - Server.serverList); | 702 | + ServerConfig.serverList); |
| 740 | 703 | ||
| 741 | - GlobalConfig.rtmpPullListFromServer = _ipManager.getServerListForUserInfo( | 704 | + GlobalConfig.rtmpPullListFinal = _ipManager.getServerListForUserInfo( |
| 742 | "RTMP_PULL", | 705 | "RTMP_PULL", |
| 743 | GlobalConfig.country, | 706 | GlobalConfig.country, |
| 744 | GlobalConfig.province, | 707 | GlobalConfig.province, |
| 745 | GlobalConfig.city, | 708 | GlobalConfig.city, |
| 746 | GlobalConfig.isp, | 709 | GlobalConfig.isp, |
| 747 | - Server.serverList); | 710 | + ServerConfig.serverList); |
| 748 | 711 | ||
| 749 | - GlobalConfig.rsPullListFromServer = _ipManager.getServerListForUserInfo( | 712 | + GlobalConfig.rsPullListFinal = _ipManager.getServerListForUserInfo( |
| 750 | "RS_PULL", | 713 | "RS_PULL", |
| 751 | GlobalConfig.country, | 714 | GlobalConfig.country, |
| 752 | GlobalConfig.province, | 715 | GlobalConfig.province, |
| 753 | GlobalConfig.city, | 716 | GlobalConfig.city, |
| 754 | GlobalConfig.isp, | 717 | GlobalConfig.isp, |
| 755 | - Server.serverList); | 718 | + ServerConfig.serverList); |
| 756 | 719 | ||
| 757 | - GlobalConfig.hlsPullListFromServer = _ipManager.getServerListForUserInfo( | 720 | + GlobalConfig.hlsPullListFinal = _ipManager.getServerListForUserInfo( |
| 758 | "HLS_PULL", | 721 | "HLS_PULL", |
| 759 | GlobalConfig.country, | 722 | GlobalConfig.country, |
| 760 | GlobalConfig.province, | 723 | GlobalConfig.province, |
| 761 | GlobalConfig.city, | 724 | GlobalConfig.city, |
| 762 | GlobalConfig.isp, | 725 | GlobalConfig.isp, |
| 763 | - Server.serverList); | 726 | + ServerConfig.serverList); |
| 764 | } | 727 | } |
| 765 | 728 | ||
| 766 | - loger.warn("Server中获取的服务器信息;") | ||
| 767 | - loger.warn(" GlobalConfig.mcuListFromServer", GlobalConfig.mcuListFromServer); | ||
| 768 | - loger.warn(" GlobalConfig.msListFromServer", GlobalConfig.msListFromServer); | ||
| 769 | - loger.warn(" GlobalConfig.rtmpPullListFromServer", GlobalConfig.rtmpPullListFromServer); | ||
| 770 | - loger.warn(" GlobalConfig.hlsPullListFromServer", GlobalConfig.hlsPullListFromServer); | ||
| 771 | - loger.warn(" GlobalConfig.rsPullListFromServer", GlobalConfig.rsPullListFromServer); | ||
| 772 | - | ||
| 773 | - | ||
| 774 | - //********选择最终使用的MCU、MS 和拉流列表******** | ||
| 775 | - //****优先使用server.json中的数据,如果没有再使用Sass中的数据**** | ||
| 776 | - | ||
| 777 | - //MCU | ||
| 778 | - GlobalConfig.mcuListFinal = []; | ||
| 779 | - if (GlobalConfig.mcuListFromServer.length > 0) { | ||
| 780 | - //使用server中的MCU数据 | ||
| 781 | - GlobalConfig.mcuListFinal = GlobalConfig.mcuListFromServer; | ||
| 782 | - } else { | ||
| 783 | - //使用Sass中的数据 | ||
| 784 | - GlobalConfig.mcuListFinal = GlobalConfig.mcuList; | 729 | + //拉流地址列表的特殊处理, |
| 730 | + // 1.如果RTMP拉流地址没有配置,就默认使用MS推流地址列表 | ||
| 731 | + if (!GlobalConfig.rtmpPullListFinal || GlobalConfig.rtmpPullListFinal.length < 1) { | ||
| 732 | + GlobalConfig.rtmpPullListFinal = GlobalConfig.msListFinal; | ||
| 785 | } | 733 | } |
| 786 | - | ||
| 787 | - //MS推流 | ||
| 788 | - GlobalConfig.msListFinal = [] | ||
| 789 | - if (GlobalConfig.msListFromServer.length > 0) { | ||
| 790 | - GlobalConfig.msListFinal = GlobalConfig.msListFromServer; | ||
| 791 | - } else { | ||
| 792 | - GlobalConfig.msListFinal = GlobalConfig.msList; | 734 | + // 2.如果HLS拉流地址没有配置,就默认使用录制回放RS拉流地址列表中的数据 |
| 735 | + if (!GlobalConfig.hlsPullListFinal || GlobalConfig.hlsPullListFinal.length < 1) { | ||
| 736 | + GlobalConfig.hlsPullListFinal = GlobalConfig.rsPullListFinal; | ||
| 793 | } | 737 | } |
| 794 | 738 | ||
| 795 | - //RS录制回放HLS拉流 | ||
| 796 | - GlobalConfig.rsListFinal = [] | ||
| 797 | - if (GlobalConfig.msListFromServer.length > 0) { | ||
| 798 | - GlobalConfig.rsListFinal = GlobalConfig.rsPullListFromServer; | ||
| 799 | - } else { | ||
| 800 | - GlobalConfig.rsListFinal = GlobalConfig.rsList; | ||
| 801 | - } | 739 | + loger.warn("课堂最终使用的服务列表->来自本地Server.json"); |
| 740 | + loger.warn(" GlobalConfig.mcuListFinal", GlobalConfig.mcuListFinal); | ||
| 741 | + loger.warn(" GlobalConfig.msListFinal", GlobalConfig.msListFinal); | ||
| 742 | + loger.warn(" GlobalConfig.rtmpPullListFinal", GlobalConfig.rtmpPullListFinal); | ||
| 743 | + loger.warn(" GlobalConfig.hlsListFinal", GlobalConfig.hlsPullListFinal); | ||
| 744 | + loger.warn(" GlobalConfig.rsListFinal", GlobalConfig.rsPullListFinal); | ||
| 745 | + } | ||
| 746 | + //从Sass中选择的mcu、ms列表 | ||
| 747 | + _choiceMcuAndMsListFromSass() { | ||
| 748 | + //1.根据user信息获取服务器列表 | ||
| 749 | + if (_ipManager) { | ||
| 750 | + GlobalConfig.mcuListFinal = _ipManager.getServerListForUserInfo( | ||
| 751 | + "MCU", | ||
| 752 | + GlobalConfig.country, | ||
| 753 | + GlobalConfig.province, | ||
| 754 | + GlobalConfig.city, | ||
| 755 | + GlobalConfig.isp, | ||
| 756 | + ServerConfig.serverList); | ||
| 802 | 757 | ||
| 803 | - //RTMP拉流 | ||
| 804 | - GlobalConfig.rtmpPullListFinal = []; | ||
| 805 | - if (GlobalConfig.rtmpPullListFromServer.length > 0) { | ||
| 806 | - GlobalConfig.rtmpPullListFinal = GlobalConfig.rtmpPullListFromServer; | ||
| 807 | - } else { | ||
| 808 | - GlobalConfig.rtmpPullListFinal = GlobalConfig.rtmpPullList; | ||
| 809 | - } | 758 | + GlobalConfig.msListFinal = _ipManager.getServerListForUserInfo( |
| 759 | + "MS", | ||
| 760 | + GlobalConfig.country, | ||
| 761 | + GlobalConfig.province, | ||
| 762 | + GlobalConfig.city, | ||
| 763 | + GlobalConfig.isp, | ||
| 764 | + ServerConfig.serverList); | ||
| 810 | 765 | ||
| 811 | - //HLS拉流流 | ||
| 812 | - GlobalConfig.hlsListFinal = []; | ||
| 813 | - if (GlobalConfig.hlsPullListFromServer.length > 0) { | ||
| 814 | - GlobalConfig.hlsListFinal = GlobalConfig.hlsPullListFromServer; | ||
| 815 | - } else { | ||
| 816 | - GlobalConfig.hlsListFinal = GlobalConfig.hlsPullList; | 766 | + GlobalConfig.rtmpPullListFinal= _ipManager.getServerListForUserInfo( |
| 767 | + "RTMP_PULL", | ||
| 768 | + GlobalConfig.country, | ||
| 769 | + GlobalConfig.province, | ||
| 770 | + GlobalConfig.city, | ||
| 771 | + GlobalConfig.isp, | ||
| 772 | + ServerConfig.serverList); | ||
| 773 | + | ||
| 774 | + GlobalConfig.rsPullListFinal = _ipManager.getServerListForUserInfo( | ||
| 775 | + "RS_PULL", | ||
| 776 | + GlobalConfig.country, | ||
| 777 | + GlobalConfig.province, | ||
| 778 | + GlobalConfig.city, | ||
| 779 | + GlobalConfig.isp, | ||
| 780 | + ServerConfig.serverList); | ||
| 781 | + | ||
| 782 | + GlobalConfig.hlsPullListFinal= _ipManager.getServerListForUserInfo( | ||
| 783 | + "HLS_PULL", | ||
| 784 | + GlobalConfig.country, | ||
| 785 | + GlobalConfig.province, | ||
| 786 | + GlobalConfig.city, | ||
| 787 | + GlobalConfig.isp, | ||
| 788 | + ServerConfig.serverList); | ||
| 817 | } | 789 | } |
| 790 | + loger.warn("Sass中获取的服务器信息;"); | ||
| 818 | 791 | ||
| 819 | //拉流地址列表的特殊处理, | 792 | //拉流地址列表的特殊处理, |
| 820 | // 1.如果RTMP拉流地址没有配置,就默认使用MS推流地址列表 | 793 | // 1.如果RTMP拉流地址没有配置,就默认使用MS推流地址列表 |
| @@ -822,20 +795,20 @@ export default class MessageEntrance extends Emiter { | @@ -822,20 +795,20 @@ export default class MessageEntrance extends Emiter { | ||
| 822 | GlobalConfig.rtmpPullListFinal = GlobalConfig.msListFinal; | 795 | GlobalConfig.rtmpPullListFinal = GlobalConfig.msListFinal; |
| 823 | } | 796 | } |
| 824 | // 2.如果HLS拉流地址没有配置,就默认使用录制回放RS拉流地址列表中的数据 | 797 | // 2.如果HLS拉流地址没有配置,就默认使用录制回放RS拉流地址列表中的数据 |
| 825 | - if (!GlobalConfig.hlsListFinal || GlobalConfig.hlsListFinal.length < 1) { | ||
| 826 | - GlobalConfig.hlsListFinal = GlobalConfig.rsListFinal; | ||
| 827 | - ; | 798 | + if (!GlobalConfig.hlsPullListFinal || GlobalConfig.hlsPullListFinal.length < 1) { |
| 799 | + GlobalConfig.hlsPullListFinal = GlobalConfig.rsPullListFinal; | ||
| 828 | } | 800 | } |
| 829 | 801 | ||
| 830 | - loger.warn("课堂最终使用的服务列表->"); | 802 | + loger.warn("课堂最终使用的服务列表->来自Sass"); |
| 831 | loger.warn(" GlobalConfig.mcuListFinal", GlobalConfig.mcuListFinal); | 803 | loger.warn(" GlobalConfig.mcuListFinal", GlobalConfig.mcuListFinal); |
| 832 | loger.warn(" GlobalConfig.msListFinal", GlobalConfig.msListFinal); | 804 | loger.warn(" GlobalConfig.msListFinal", GlobalConfig.msListFinal); |
| 833 | loger.warn(" GlobalConfig.rtmpPullListFinal", GlobalConfig.rtmpPullListFinal); | 805 | loger.warn(" GlobalConfig.rtmpPullListFinal", GlobalConfig.rtmpPullListFinal); |
| 834 | - loger.warn(" GlobalConfig.hlsListFinal", GlobalConfig.hlsListFinal); | ||
| 835 | - loger.warn(" GlobalConfig.rsListFinal", GlobalConfig.rsListFinal); | 806 | + loger.warn(" GlobalConfig.hlsListFinal", GlobalConfig.hlsPullListFinal); |
| 807 | + loger.warn(" GlobalConfig.rsListFinal", GlobalConfig.rsPullListFinal); | ||
| 836 | 808 | ||
| 837 | } | 809 | } |
| 838 | 810 | ||
| 811 | + | ||
| 839 | //开始测速 | 812 | //开始测速 |
| 840 | _getFastestIpFromServer(_dataArr, _callback) { | 813 | _getFastestIpFromServer(_dataArr, _callback) { |
| 841 | if (_ipManager) { | 814 | if (_ipManager) { |
| @@ -1042,10 +1015,10 @@ export default class MessageEntrance extends Emiter { | @@ -1042,10 +1015,10 @@ export default class MessageEntrance extends Emiter { | ||
| 1042 | GlobalConfig.MCUServerPort = _data.port || ""; | 1015 | GlobalConfig.MCUServerPort = _data.port || ""; |
| 1043 | } else { | 1016 | } else { |
| 1044 | //随机选择一个 | 1017 | //随机选择一个 |
| 1045 | - if (GlobalConfig.mcuList && GlobalConfig.mcuList.length > 0) { | ||
| 1046 | - let index = parseInt(Math.random() * GlobalConfig.mcuList.length); | ||
| 1047 | - GlobalConfig.MCUServerIP = GlobalConfig.mcuList[index].ip || ""; | ||
| 1048 | - GlobalConfig.MCUServerPort = GlobalConfig.mcuList[index].port || ""; | 1018 | + if (GlobalConfig.mcuListFinal && GlobalConfig.mcuListFinal.length > 0) { |
| 1019 | + let index = parseInt(Math.random() * GlobalConfig.mcuListFinal.length); | ||
| 1020 | + GlobalConfig.MCUServerIP = GlobalConfig.mcuListFinal[index].ip || ""; | ||
| 1021 | + GlobalConfig.MCUServerPort = GlobalConfig.mcuListFinal[index].port || ""; | ||
| 1049 | } | 1022 | } |
| 1050 | } | 1023 | } |
| 1051 | if (oldIp && oldIp != GlobalConfig.MCUServerIP) { | 1024 | if (oldIp && oldIp != GlobalConfig.MCUServerIP) { |
| @@ -1167,7 +1140,7 @@ export default class MessageEntrance extends Emiter { | @@ -1167,7 +1140,7 @@ export default class MessageEntrance extends Emiter { | ||
| 1167 | loger.warn('录制回放->不进行MS-HLS动态选点'); | 1140 | loger.warn('录制回放->不进行MS-HLS动态选点'); |
| 1168 | return; | 1141 | return; |
| 1169 | } | 1142 | } |
| 1170 | - if(!GlobalConfig.hlsListFinal||GlobalConfig.hlsListFinal.length<1){ | 1143 | + if(!GlobalConfig.hlsPullListFinal||GlobalConfig.hlsPullListFinal.length<1){ |
| 1171 | return; | 1144 | return; |
| 1172 | } | 1145 | } |
| 1173 | let _this = this; | 1146 | let _this = this; |
| @@ -1178,10 +1151,10 @@ export default class MessageEntrance extends Emiter { | @@ -1178,10 +1151,10 @@ export default class MessageEntrance extends Emiter { | ||
| 1178 | GlobalConfig.MS_PLAY_HLS_PORT = _data.port || ""; | 1151 | GlobalConfig.MS_PLAY_HLS_PORT = _data.port || ""; |
| 1179 | } else { | 1152 | } else { |
| 1180 | //随机选择一个 | 1153 | //随机选择一个 |
| 1181 | - if (GlobalConfig.hlsListFinal && GlobalConfig.hlsListFinal.length > 0) { | ||
| 1182 | - let index = parseInt(Math.random() * GlobalConfig.hlsListFinal.length); | ||
| 1183 | - GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsListFinal[index].ip || ""; | ||
| 1184 | - GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsListFinal[index].port || ""; | 1154 | + if (GlobalConfig.hlsPullListFinal && GlobalConfig.hlsPullListFinal.length > 0) { |
| 1155 | + let index = parseInt(Math.random() * GlobalConfig.hlsPullListFinal.length); | ||
| 1156 | + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsPullListFinal[index].ip || ""; | ||
| 1157 | + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsPullListFinal[index].port || ""; | ||
| 1185 | } | 1158 | } |
| 1186 | } | 1159 | } |
| 1187 | //如果HLS没有配置地址,那么还是使用推流的地址 | 1160 | //如果HLS没有配置地址,那么还是使用推流的地址 |
| @@ -1440,14 +1413,41 @@ export default class MessageEntrance extends Emiter { | @@ -1440,14 +1413,41 @@ export default class MessageEntrance extends Emiter { | ||
| 1440 | loger.warn("服务器时间:" + GlobalConfig.serverTime + " 系统时间:" + new Date().getTime() + " 时间差:" + GlobalConfig.serverAndLoacTimeDistanc); | 1413 | loger.warn("服务器时间:" + GlobalConfig.serverTime + " 系统时间:" + new Date().getTime() + " 时间差:" + GlobalConfig.serverAndLoacTimeDistanc); |
| 1441 | 1414 | ||
| 1442 | GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表 | 1415 | GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表 |
| 1443 | - GlobalConfig.setRecordList(_data.recordList); //录制回放地址 | 1416 | + GlobalConfig.setRecordList(_data.recordList); //录制回放文件地址 |
| 1444 | GlobalConfig.setDocList(_data.docList); //文档地址 | 1417 | GlobalConfig.setDocList(_data.docList); //文档地址 |
| 1445 | GlobalConfig.setMusicList(_data.musicList); // | 1418 | GlobalConfig.setMusicList(_data.musicList); // |
| 1446 | GlobalConfig.setMusicListPrepare(_data.musicListPrepare); //提前上传的声音文件列表 | 1419 | GlobalConfig.setMusicListPrepare(_data.musicListPrepare); //提前上传的声音文件列表 |
| 1447 | GlobalConfig.setVideoCDNAddr(_data.videoCDNAddr); //cdn加速的拉流地址,直播的时候才使用 | 1420 | GlobalConfig.setVideoCDNAddr(_data.videoCDNAddr); //cdn加速的拉流地址,直播的时候才使用 |
| 1448 | GlobalConfig.setMediaShareList(_data.sharedMediaList); //提前上传的媒体共享文件列表 | 1421 | GlobalConfig.setMediaShareList(_data.sharedMediaList); //提前上传的媒体共享文件列表 |
| 1449 | 1422 | ||
| 1423 | + | ||
| 1424 | + //文档服务器地址 | ||
| 1425 | + if (GlobalConfig.docList && GlobalConfig.docList.length > 0) { | ||
| 1426 | + //doc上传地址,随机获取一个 | ||
| 1427 | + let index = parseInt(Math.random() * GlobalConfig.docList.length); | ||
| 1428 | + GlobalConfig.DOCServerIP = GlobalConfig.docList[index].ip || ""; | ||
| 1429 | + GlobalConfig.DOCServerPort = GlobalConfig.docList[index].port || ""; | ||
| 1430 | + | ||
| 1431 | + } | ||
| 1432 | + //录制回放文件的下载地址 | ||
| 1433 | + if (GlobalConfig.recordList && GlobalConfig.recordList.length > 0) { | ||
| 1434 | + let index = parseInt(Math.random() * GlobalConfig.recordList.length); | ||
| 1435 | + GlobalConfig.RecordServerIP = GlobalConfig.recordList[index].ip || ""; | ||
| 1436 | + GlobalConfig.RecordServerPort = GlobalConfig.recordList[index].port || ""; | ||
| 1437 | + } | ||
| 1438 | + loger.warn('默认->文档服务器地址->.', GlobalConfig.DOCServerIP, GlobalConfig.DOCServerPort); | ||
| 1439 | + loger.warn('默认->录制回放文件下载地址->.', GlobalConfig.RecordServerIP, GlobalConfig.RecordServerPort); | ||
| 1440 | + | ||
| 1441 | + | ||
| 1450 | //存从Sass获取的MS和MCU服务列表 | 1442 | //存从Sass获取的MS和MCU服务列表 |
| 1443 | + let serverJsonStr=_data.serverJson; | ||
| 1444 | + try{ | ||
| 1445 | + ServerConfig.sassServerJson=JSON.parse(serverJsonStr);///Sass返回的Server数据 | ||
| 1446 | + }catch (err){ | ||
| 1447 | + loger.error("从SASS获取的SERVER数据解析失败",err.message); | ||
| 1448 | + } | ||
| 1449 | + | ||
| 1450 | + /* | ||
| 1451 | if (_data.msList2) { | 1451 | if (_data.msList2) { |
| 1452 | GlobalConfig.setMsList(_data.msList2.msList); //储存Sass ms拉流地址 | 1452 | GlobalConfig.setMsList(_data.msList2.msList); //储存Sass ms拉流地址 |
| 1453 | GlobalConfig.setRtmpPullList(_data.msList2.rtmpPullArray); //储存Sass ms拉流地址 | 1453 | GlobalConfig.setRtmpPullList(_data.msList2.rtmpPullArray); //储存Sass ms拉流地址 |
| @@ -1457,19 +1457,25 @@ export default class MessageEntrance extends Emiter { | @@ -1457,19 +1457,25 @@ export default class MessageEntrance extends Emiter { | ||
| 1457 | //Sass mcu | 1457 | //Sass mcu |
| 1458 | GlobalConfig.setMcuList(_data.mcuList); //mcu | 1458 | GlobalConfig.setMcuList(_data.mcuList); //mcu |
| 1459 | 1459 | ||
| 1460 | + | ||
| 1460 | loger.warn('从Sass获取的推流拉流列表数据:'); | 1461 | loger.warn('从Sass获取的推流拉流列表数据:'); |
| 1461 | loger.warn('Sass->msList->', GlobalConfig.msList); | 1462 | loger.warn('Sass->msList->', GlobalConfig.msList); |
| 1462 | loger.warn('Sass->rtmpPullList->', GlobalConfig.rtmpPullList); | 1463 | loger.warn('Sass->rtmpPullList->', GlobalConfig.rtmpPullList); |
| 1463 | loger.warn('Sass->hlsPullList->', GlobalConfig.hlsPullList); | 1464 | loger.warn('Sass->hlsPullList->', GlobalConfig.hlsPullList); |
| 1464 | loger.warn('Sass->rsList->', GlobalConfig.rsList); | 1465 | loger.warn('Sass->rsList->', GlobalConfig.rsList); |
| 1465 | 1466 | ||
| 1466 | - //获取MCU和MS 推流拉流、录制回放的默认地址,后面还会进行测速选择 | ||
| 1467 | - this.getMcuAndMsDefaultServerIp(); | 1467 | + //没有加载server.json之前,最终的服务列表按Sass的为准,server.json加载完成后会选点 |
| 1468 | + GlobalConfig.msListFinal=GlobalConfig.msList; | ||
| 1469 | + GlobalConfig.rtmpPullListFinal=GlobalConfig.rtmpPullList; | ||
| 1470 | + GlobalConfig.hlsListFinal=GlobalConfig.hlsPullList; | ||
| 1471 | + GlobalConfig.rsListFinal=GlobalConfig.rsList; | ||
| 1472 | + GlobalConfig.mcuListFinal=GlobalConfig.mcuList;*/ | ||
| 1468 | } | 1473 | } |
| 1469 | 1474 | ||
| 1470 | //课堂获取Sass数据完成 | 1475 | //课堂获取Sass数据完成 |
| 1471 | this._emit(MessageTypes.CLASS_GET_INFO_SUCCESS, GlobalConfig.getClassInfo()); | 1476 | this._emit(MessageTypes.CLASS_GET_INFO_SUCCESS, GlobalConfig.getClassInfo()); |
| 1472 | 1477 | ||
| 1478 | + //存储Sass数据到本地 | ||
| 1473 | if (_data.currentInfo) { | 1479 | if (_data.currentInfo) { |
| 1474 | //根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息 | 1480 | //根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息 |
| 1475 | try { | 1481 | try { |
| @@ -1490,6 +1496,11 @@ export default class MessageEntrance extends Emiter { | @@ -1490,6 +1496,11 @@ export default class MessageEntrance extends Emiter { | ||
| 1490 | if (_recordPlayback) { | 1496 | if (_recordPlayback) { |
| 1491 | //开启录制回放流程 | 1497 | //开启录制回放流程 |
| 1492 | loger.warn("开启录制回放流程"); | 1498 | loger.warn("开启录制回放流程"); |
| 1499 | + //根据用户的userIp信息从sever.json和Sass中选择最终mcu和推流拉流数据列表 | ||
| 1500 | + ServerConfig.serverList=ServerConfig.sassServerJson; | ||
| 1501 | + this._choiceMcuAndMsListFromSass(); | ||
| 1502 | + //获取MCU和MS 推流拉流、录制回放的默认地址 | ||
| 1503 | + this.getMcuAndMsDefaultServerIp(); | ||
| 1493 | _recordPlayback.readyRecordPlay(); | 1504 | _recordPlayback.readyRecordPlay(); |
| 1494 | } else { | 1505 | } else { |
| 1495 | loger.warn("开启录制回放流程失败->还未创建模块"); | 1506 | loger.warn("开启录制回放流程失败->还未创建模块"); |
| @@ -1503,35 +1514,35 @@ export default class MessageEntrance extends Emiter { | @@ -1503,35 +1514,35 @@ export default class MessageEntrance extends Emiter { | ||
| 1503 | //获取各个服务的默认ip,之后会进行测速选择更快的ip | 1514 | //获取各个服务的默认ip,之后会进行测速选择更快的ip |
| 1504 | getMcuAndMsDefaultServerIp() { | 1515 | getMcuAndMsDefaultServerIp() { |
| 1505 | //MCU地址 | 1516 | //MCU地址 |
| 1506 | - if (GlobalConfig.mcuList && GlobalConfig.mcuList.length > 0) { | 1517 | + if (GlobalConfig.mcuListFinal && GlobalConfig.mcuListFinal.length > 0) { |
| 1507 | //还未开始选点之前随机选择一个 | 1518 | //还未开始选点之前随机选择一个 |
| 1508 | - let index = parseInt(Math.random() * GlobalConfig.mcuList.length); | ||
| 1509 | - GlobalConfig.MCUServerIP = GlobalConfig.mcuList[index].ip || ""; | ||
| 1510 | - GlobalConfig.MCUServerPort = GlobalConfig.mcuList[index].port || ""; | 1519 | + let index = parseInt(Math.random() * GlobalConfig.mcuListFinal.length); |
| 1520 | + GlobalConfig.MCUServerIP = GlobalConfig.mcuListFinal[index].ip || ""; | ||
| 1521 | + GlobalConfig.MCUServerPort = GlobalConfig.mcuListFinal[index].port || ""; | ||
| 1511 | } | 1522 | } |
| 1512 | 1523 | ||
| 1513 | //录制回放时m3u8播流地址 | 1524 | //录制回放时m3u8播流地址 |
| 1514 | - if (GlobalConfig.rsList && GlobalConfig.rsList.length > 0) { | 1525 | + if (GlobalConfig.rsPullListFinal && GlobalConfig.rsPullListFinal.length > 0) { |
| 1515 | //还未开始选点之前随机选择一个 | 1526 | //还未开始选点之前随机选择一个 |
| 1516 | - let index = parseInt(Math.random() * GlobalConfig.rsList.length); | ||
| 1517 | - GlobalConfig.RS_RECORD_PLAY_IP = GlobalConfig.rsList[index].ip || ""; | ||
| 1518 | - GlobalConfig.RS_RECORD_PLAY_PORT = GlobalConfig.rsList[index].port || ""; | 1527 | + let index = parseInt(Math.random() * GlobalConfig.rsPullListFinal.length); |
| 1528 | + GlobalConfig.RS_RECORD_PLAY_IP = GlobalConfig.rsPullListFinal[index].ip || ""; | ||
| 1529 | + GlobalConfig.RS_RECORD_PLAY_PORT = GlobalConfig.rsPullListFinal[index].port || ""; | ||
| 1519 | } | 1530 | } |
| 1520 | 1531 | ||
| 1521 | //推流地址 | 1532 | //推流地址 |
| 1522 | - if (GlobalConfig.msList && GlobalConfig.msList.length > 0) { | 1533 | + if (GlobalConfig.msListFinal && GlobalConfig.msListFinal.length > 0) { |
| 1523 | //还未开始选点之前随机选择一个 | 1534 | //还未开始选点之前随机选择一个 |
| 1524 | - let index = parseInt(Math.random() * GlobalConfig.msList.length); | ||
| 1525 | - GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msList[index].ip || ""; | ||
| 1526 | - GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msList[index].port || ""; | 1535 | + let index = parseInt(Math.random() * GlobalConfig.msListFinal.length); |
| 1536 | + GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msListFinal[index].ip || ""; | ||
| 1537 | + GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msListFinal[index].port || ""; | ||
| 1527 | } | 1538 | } |
| 1528 | 1539 | ||
| 1529 | //RTMP拉流 | 1540 | //RTMP拉流 |
| 1530 | - if (GlobalConfig.rtmpPullList && GlobalConfig.rtmpPullList.length > 0) { | 1541 | + if (GlobalConfig.rtmpPullListFinal && GlobalConfig.rtmpPullListFinal.length > 0) { |
| 1531 | // //还未开始选点之前随机选择一个 | 1542 | // //还未开始选点之前随机选择一个 |
| 1532 | - let index = parseInt(Math.random() * GlobalConfig.rtmpPullList.length); | ||
| 1533 | - GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.rtmpPullList[index].ip || ""; | ||
| 1534 | - GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.rtmpPullList[index].port || ""; | 1543 | + let index = parseInt(Math.random() * GlobalConfig.rtmpPullListFinal.length); |
| 1544 | + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.rtmpPullListFinal[index].ip || ""; | ||
| 1545 | + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.rtmpPullListFinal[index].port || ""; | ||
| 1535 | } else { | 1546 | } else { |
| 1536 | //如果没有单独的rtmp拉流地址,和推流地址一样即可 | 1547 | //如果没有单独的rtmp拉流地址,和推流地址一样即可 |
| 1537 | GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP; | 1548 | GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP; |
| @@ -1539,33 +1550,17 @@ export default class MessageEntrance extends Emiter { | @@ -1539,33 +1550,17 @@ export default class MessageEntrance extends Emiter { | ||
| 1539 | } | 1550 | } |
| 1540 | 1551 | ||
| 1541 | //课堂中HLS拉流地址 | 1552 | //课堂中HLS拉流地址 |
| 1542 | - if (GlobalConfig.hlsPullList && GlobalConfig.hlsPullList.length > 0) { | 1553 | + if (GlobalConfig.hlsPullListFinal && GlobalConfig.hlsPullListFinal.length > 0) { |
| 1543 | //有单独的hls拉流地址 | 1554 | //有单独的hls拉流地址 |
| 1544 | - let index = parseInt(Math.random() * GlobalConfig.hlsPullList.length); | ||
| 1545 | - GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsPullList[index].ip || ""; | ||
| 1546 | - GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsPullList[index].port || ""; | 1555 | + let index = parseInt(Math.random() * GlobalConfig.hlsPullListFinal.length); |
| 1556 | + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsPullListFinal[index].ip || ""; | ||
| 1557 | + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsPullListFinal[index].port || ""; | ||
| 1547 | } else { | 1558 | } else { |
| 1548 | //没有单独的hls拉流地址,和录制回放地址一样即可 | 1559 | //没有单独的hls拉流地址,和录制回放地址一样即可 |
| 1549 | GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP; | 1560 | GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP; |
| 1550 | GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT; | 1561 | GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT; |
| 1551 | } | 1562 | } |
| 1552 | 1563 | ||
| 1553 | - | ||
| 1554 | - //文档服务器地址 | ||
| 1555 | - if (GlobalConfig.docList && GlobalConfig.docList.length > 0) { | ||
| 1556 | - //doc上传地址,随机获取一个 | ||
| 1557 | - let index = parseInt(Math.random() * GlobalConfig.docList.length); | ||
| 1558 | - GlobalConfig.DOCServerIP = GlobalConfig.docList[index].ip || ""; | ||
| 1559 | - GlobalConfig.DOCServerPort = GlobalConfig.docList[index].port || ""; | ||
| 1560 | - | ||
| 1561 | - } | ||
| 1562 | - //录制回放文件的下载地址 | ||
| 1563 | - if (GlobalConfig.recordList && GlobalConfig.recordList.length > 0) { | ||
| 1564 | - let index = parseInt(Math.random() * GlobalConfig.recordList.length); | ||
| 1565 | - GlobalConfig.RecordServerIP = GlobalConfig.recordList[index].ip || ""; | ||
| 1566 | - GlobalConfig.RecordServerPort = GlobalConfig.recordList[index].port || ""; | ||
| 1567 | - | ||
| 1568 | - } | ||
| 1569 | loger.warn('默认->MCU地址->.', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); | 1564 | loger.warn('默认->MCU地址->.', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); |
| 1570 | 1565 | ||
| 1571 | loger.warn('默认->MS推流地址->.', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT); | 1566 | loger.warn('默认->MS推流地址->.', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT); |
| @@ -1573,8 +1568,6 @@ export default class MessageEntrance extends Emiter { | @@ -1573,8 +1568,6 @@ export default class MessageEntrance extends Emiter { | ||
| 1573 | loger.warn('默认->HLS拉流地址->.', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT); | 1568 | loger.warn('默认->HLS拉流地址->.', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT); |
| 1574 | loger.warn('默认->RTMP拉流地址->.', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT); | 1569 | loger.warn('默认->RTMP拉流地址->.', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT); |
| 1575 | 1570 | ||
| 1576 | - loger.warn('默认->文档服务器地址->.', GlobalConfig.DOCServerIP, GlobalConfig.DOCServerPort); | ||
| 1577 | - loger.warn('默认->录制回放文件下载地址->.', GlobalConfig.RecordServerIP, GlobalConfig.RecordServerPort); | ||
| 1578 | } | 1571 | } |
| 1579 | 1572 | ||
| 1580 | //获取课堂所有参数 api/meeting/detail.do? flash中的接口文件是 getClassParam.do(20170727之前的规则) | 1573 | //获取课堂所有参数 api/meeting/detail.do? flash中的接口文件是 getClassParam.do(20170727之前的规则) |
src/EngineEntranceOld.js
0 → 100644
| 1 | +require('es6-promise').polyfill(); | ||
| 2 | +require('whatwg-fetch'); | ||
| 3 | +require('jquery-touchswipe'); | ||
| 4 | +require('string.fromcodepoint'); | ||
| 5 | +//require('messenger'); | ||
| 6 | + | ||
| 7 | +import Emiter from './Emiter'; | ||
| 8 | +import Sass from 'Sass'; | ||
| 9 | +import IpManager from 'IpManager'; | ||
| 10 | +import RecordPlayBackParse from 'RecordPlayBackParse'; | ||
| 11 | +import MD5 from "md5"; | ||
| 12 | +import Mcu from 'mcu'; | ||
| 13 | +import MessageTypes from 'MessageTypes'; | ||
| 14 | +import Loger from 'Loger'; | ||
| 15 | +import ConferApe from 'apes/ConferApe'; | ||
| 16 | +import ChatApe from 'apes/ChatApe'; | ||
| 17 | +import VideoApe from 'apes/VideoApe'; | ||
| 18 | +import AudioApe from 'apes/AudioApe'; | ||
| 19 | +import DocApe from 'apes/DocApe'; | ||
| 20 | +import WhiteBoardApe from 'apes/WhiteBoardApe'; | ||
| 21 | +import CursorApe from 'apes/CursorApe'; | ||
| 22 | + | ||
| 23 | +import EngineUtils from "EngineUtils"; | ||
| 24 | +import GlobalConfig from 'GlobalConfig'; | ||
| 25 | +import SystemConfig from 'SystemConfig'; | ||
| 26 | + | ||
| 27 | +import ApeConsts from 'apes/ApeConsts'; | ||
| 28 | +import Base64 from 'base64-js'; | ||
| 29 | +import ArrayBufferUtil from 'libs/ArrayBufferUtil'; | ||
| 30 | +import Server from "config/Server"; | ||
| 31 | +import MediaModule from 'apes/MediaModule'; | ||
| 32 | +import MediaSharedApe from 'apes/MediaSharedApe'; | ||
| 33 | +import MusicSharedApe from 'apes/MusicSharedApe'; | ||
| 34 | +import QuestionApe from 'apes/QuestionApe'; | ||
| 35 | +import UTF8 from 'utf-8'; | ||
| 36 | + | ||
| 37 | +let loger = Loger.getLoger('McuClient'); | ||
| 38 | +let _sdkInfo = {"version": "v1.55.1.20170727", "author": "www.3mang.com"}; | ||
| 39 | + | ||
| 40 | +//APE | ||
| 41 | +let _sass; | ||
| 42 | +let _ipManager; | ||
| 43 | +let _mcu; | ||
| 44 | +let _confer_ape; | ||
| 45 | +let _chat_ape; | ||
| 46 | +let _video_ape; | ||
| 47 | +let _audio_ape; | ||
| 48 | +let _doc_ape; | ||
| 49 | +let _whiteboard_ape; | ||
| 50 | +let _cursor_ape; | ||
| 51 | +let _recordPlayback; | ||
| 52 | +let _mediaShareApe; | ||
| 53 | +let _musicShareApe; | ||
| 54 | +let _questionApe; | ||
| 55 | + | ||
| 56 | +//MCUClient 外部实例化主类 | ||
| 57 | +export default class EngineEntranceOld extends Emiter { | ||
| 58 | + constructor() { | ||
| 59 | + super(); | ||
| 60 | + //sdk 信息 | ||
| 61 | + this.sdkInfo = _sdkInfo; | ||
| 62 | + loger.warn(this.sdkInfo); | ||
| 63 | + //获取设备和系统信息 | ||
| 64 | + SystemConfig.getSystemInfo(); | ||
| 65 | + | ||
| 66 | + this.classRecordStatusUpdateTimer = 0; //课堂录制状态发生改变后同步当前所有模块数据的计时器 | ||
| 67 | + //初始化状态 | ||
| 68 | + this.isGetUserIpCallback = false; //是否获取IP信息返回 | ||
| 69 | + this.isGetFastestMcuCallback = false; //是否MCU测速结束 | ||
| 70 | + this.isGetFastestMsCallback = false; //是否MS测速结束 | ||
| 71 | + this.isGetFastestRtmpPullCallback = false; //是否RTMP拉流地址测试结束 | ||
| 72 | + this.isGetFastestHlsPullCallback = false; //是否HLS拉流地址测试结束 | ||
| 73 | + this.isGetFastestRsCallback = false; //是否录制回放HLS拉流地址测试结束 | ||
| 74 | + | ||
| 75 | + //全局的Error处理 | ||
| 76 | + this.on(MessageTypes.MCU_ERROR, this._mcuErrorHandler.bind(this)); | ||
| 77 | + | ||
| 78 | + // Sass平台层 | ||
| 79 | + _sass = Sass; | ||
| 80 | + _sass.on('*', (type, data) => this._emit(type, data)); | ||
| 81 | + _sass.on(_sass.SUCCESS, this._sassJoinSuccessHandler.bind(this)); //通过SASS平台验证(密码和MD5) | ||
| 82 | + _sass.on(_sass.CLASS_INIT_SUCCESS, this._sassInitSuccessHandler.bind(this)); //获取课堂初始化信息 | ||
| 83 | + //_sass.on(_sass.CLASS_GET_CLASS_DETAIL, this._sassGetClassDetailSuccessHandler.bind(this));//获取课堂的基本信息 | ||
| 84 | + _sass.on(_sass.CLASS_GET_CLASS_PARAM, this._sassGetClassParamSuccessHandler.bind(this)); //获取课堂的最全信息和历史保存的数据 | ||
| 85 | + | ||
| 86 | + _sass.on(_sass.CLASS_SAVE_STATUS_INFO_SUCCESS, this._sassSaveClassStatusInfoSuccessHandler.bind(this)); //保存课堂状态信息 | ||
| 87 | + _sass.on(_sass.CLASS_SAVE_RECORD_INFO_SUCCESS, this._sassSaveClassRecordInfoSuccessHandler.bind(this)); //保存课堂录制信息 | ||
| 88 | + _sass.on(_sass.DELETE_DOCUMENT_SUCCESS, this._sassDeleteDocumentSuccess.bind(this)); //sass删除文档成功 | ||
| 89 | + _sass.on(_sass.DELETE_MEDIASHARE_SUCCESS, this._sassDeleteMediaShareSuccess.bind(this)); //sass删除媒体文件成功 | ||
| 90 | + _sass.on(_sass.DELETE_MUSICSHARE_SUCCESS, this._sassDeleteMusicShareSuccess.bind(this)); //sass删除MUSIC文件成功 | ||
| 91 | + | ||
| 92 | + //选点模块 | ||
| 93 | + _ipManager = new IpManager(); | ||
| 94 | + | ||
| 95 | + // 底层MCU消息层 | ||
| 96 | + _mcu = Mcu; | ||
| 97 | + _mcu.on('*', (type, data) => this._emit(type, data)); | ||
| 98 | + _mcu.on(MessageTypes.CLASS_JOIN_MCU_SUCCESS, this._mcuJoinMCUClassSuccessHandler.bind(this)); //加入MCU课堂完成 | ||
| 99 | + _mcu.on(MessageTypes.SWITCH_MCU_IP, this._switchMcuIpHandler.bind(this)); //切换MCU,重新选点 | ||
| 100 | + | ||
| 101 | + //录制回放 | ||
| 102 | + _recordPlayback = RecordPlayBackParse; | ||
| 103 | + _recordPlayback.on('*', (type, data) => this._emit(type, data)); | ||
| 104 | + _recordPlayback.on(RecordPlayBackParse.CLASS_JOIN_RECORD_PLAYBACK_SUCCESS, this._joinRecordPlaybackSuccessHandler.bind(this)); //加入录制回放完成 | ||
| 105 | + _recordPlayback.on(RecordPlayBackParse.RECORD_PLAYBACK_CLEAR_DATA, this._recordPlaybackClearDataHandler.bind(this)); //录制回放状态更新 | ||
| 106 | + | ||
| 107 | + // 注册所有应用Ape | ||
| 108 | + _confer_ape = new ConferApe(); | ||
| 109 | + _confer_ape.on('*', (type, data) => this._emit(type, data)); | ||
| 110 | + _confer_ape.on(MessageTypes.CLASS_RUN_EXIT, this._runClassExit.bind(this)); //监听自己的关闭事件 | ||
| 111 | + _confer_ape.on(MessageTypes.CLASS_STATUS_INFO_CHANGE, this._onClassStatusInfoChange.bind(this)); //当前课堂状态信息发生改变 | ||
| 112 | + _confer_ape.on(MessageTypes.CLASS_DELETE_ROSTER, this._onClassDeleteRoster.bind(this)); //当前课堂人员离开 | ||
| 113 | + _confer_ape.on(MessageTypes.CLASS_NONENTITY_ROSTER, this._onClassNonentityRoster.bind(this)); //当前课堂中视频或音频占用channel的nodeId ,在人员列表中不存在 | ||
| 114 | + _confer_ape.on(MessageTypes.CLASS_RECORD_START, this._onClassRecordStart.bind(this)); //课堂开始录制 | ||
| 115 | + _confer_ape.on(MessageTypes.CLASS_RECORD_SUCCESS, this._onClassRecordSuccess.bind(this)); //课堂开启录制成功 | ||
| 116 | + _confer_ape.on(MessageTypes.SWITCH_MS_IP, this._switchMsIpHandler.bind(this)); //MS动态选点 | ||
| 117 | + //_confer_ape.on(MessageTypes.SWITCH_RTMP_PULL_IP, this._switchRtmpPullIpHandler.bind(this)); //MS 拉流地址动态选点 | ||
| 118 | + //_confer_ape.on(MessageTypes.SWITCH_HLS_IP, this._switchHlsIpHandler.bind(this)); //MS HLS动态选点 | ||
| 119 | + _confer_ape.on(MessageTypes.STOP_ALL_MEDIA_PUBLISH, this._stopAllMediaPublishHandler.bind(this)); //课堂状态发生改变,需要停止当前的所有推流 | ||
| 120 | + | ||
| 121 | + _chat_ape = new ChatApe(); | ||
| 122 | + _chat_ape.on('*', (type, data) => this._emit(type, data)); | ||
| 123 | + | ||
| 124 | + _video_ape = new VideoApe(); | ||
| 125 | + _video_ape.on('*', (type, data) => this._emit(type, data)); | ||
| 126 | + _video_ape.on(MessageTypes.VIDEO_UPDATE, this.videoUpdate.bind(this)); //这个监听事件不能删除,需要通知课堂模块,检查channel占用 | ||
| 127 | + _video_ape.on(MessageTypes.USER_DEVICE_STATUS_CHAANGE, this.userDeviecStatusChange.bind(this)); //监听摄像头和麦克风的开启状态 | ||
| 128 | + | ||
| 129 | + _audio_ape = new AudioApe(); | ||
| 130 | + _audio_ape.on('*', (type, data) => this._emit(type, data)); | ||
| 131 | + _audio_ape.on(MessageTypes.AUDIO_UPDATE, this.audioUpdate.bind(this)); //这个监听事件不能删除,需要通知课堂模块,检查channel占用 | ||
| 132 | + _audio_ape.on(MessageTypes.USER_DEVICE_STATUS_CHAANGE, this.userDeviecStatusChange.bind(this)); //监听摄像头和麦克风的开启状态 | ||
| 133 | + | ||
| 134 | + _mediaShareApe = new MediaSharedApe(); | ||
| 135 | + _mediaShareApe.on('*', (type, data) => this._emit(type, data)); | ||
| 136 | + _mediaShareApe.on(MediaSharedApe.MEDIASHARED_JOIN_CHANNEL_SUCCESS, this.mediaShareApeJoinChannelSuccess.bind(this)); | ||
| 137 | + | ||
| 138 | + _musicShareApe = new MusicSharedApe(); | ||
| 139 | + _musicShareApe.on('*', (type, data) => this._emit(type, data)); | ||
| 140 | + _musicShareApe.on(MusicSharedApe.MUSICSHARED_JOIN_CHANNEL_SUCCESS, this.musicShareApeJoinChannelSuccess.bind(this)); | ||
| 141 | + | ||
| 142 | + _whiteboard_ape = new WhiteBoardApe(); | ||
| 143 | + _whiteboard_ape.on('*', (type, data) => this._emit(type, data)); | ||
| 144 | + | ||
| 145 | + _cursor_ape = new CursorApe(); | ||
| 146 | + _cursor_ape.on('*', (type, data) => this._emit(type, data)); | ||
| 147 | + | ||
| 148 | + _doc_ape = new DocApe(); | ||
| 149 | + _doc_ape.on('*', (type, data) => this._emit(type, data)); | ||
| 150 | + _doc_ape.on(MessageTypes.DOC_UPDATE, this.docUpdateHandler.bind(this)); | ||
| 151 | + _doc_ape.on(MessageTypes.DOC_DELETE, this.docDeleteHandler.bind(this)); | ||
| 152 | + _doc_ape.on(DocApe.DOC_JOIN_CHANNEL_SUCCESS, this.docJoinChannelSuccess.bind(this)); | ||
| 153 | + | ||
| 154 | + _questionApe = new QuestionApe(); | ||
| 155 | + _questionApe.on('*', (type, data) => this._emit(type, data)); | ||
| 156 | + | ||
| 157 | + //公开外部调用的方法 | ||
| 158 | + //class | ||
| 159 | + this.init = this._init.bind(this); | ||
| 160 | + this.joinClass = this._joinClass.bind(this); | ||
| 161 | + this.leaveClass = this._leaveClass.bind(this); | ||
| 162 | + this.getMcuClientStatus = this._getMcuClientStatus.bind(this); | ||
| 163 | + this.getClassStatusInfo = this._getClassStatusInfo.bind(this); | ||
| 164 | + this.sendStartClass = this._sendStartClass.bind(this); | ||
| 165 | + this.silenceClass = this._silenceClass.bind(this); | ||
| 166 | + this.sendPauseClass = this._sendPauseClass.bind(this); | ||
| 167 | + this.sendCloseClass = this._sendCloseClass.bind(this); | ||
| 168 | + this.changeHandUpStatus = this._changeHandUpStatus.bind(this); //自己切换举手状态 | ||
| 169 | + this.controlHandUpStatus = this._controlHandUpStatus.bind(this); //控制别人的举手状态 | ||
| 170 | + this.controlSilenceStatus = this._controlSilenceStatus.bind(this); //改变禁言状态 | ||
| 171 | + | ||
| 172 | + this.sceneTableChange = this._sceneTableChange.bind(this); //切换模块显示 | ||
| 173 | + | ||
| 174 | + this.kickOutRosterFormNodeId = this._kickOutRosterFormNodeId.bind(this); //把指定nodeId的人踢出课堂 | ||
| 175 | + | ||
| 176 | + this.sendThridChannelMessage = this._sendThridChannelMessage.bind(this);//通道第三方消息通道发送消息 | ||
| 177 | + | ||
| 178 | + //录制回放 | ||
| 179 | + this.initRecordPlayback = this._initRecordPlayback.bind(this); | ||
| 180 | + this.startRecordPlayback = this._startRecordPlayback.bind(this); | ||
| 181 | + this.stopRecordPlayback = this._stopRecordPlayback.bind(this); | ||
| 182 | + this.pauseRecordPlayback = this._pauseRecordPlayback.bind(this); | ||
| 183 | + this.seekRecordPlayback = this._seekRecordPlayback.bind(this); | ||
| 184 | + | ||
| 185 | + //chatApe | ||
| 186 | + this.sendChatMsg = this._sendChatMsg.bind(this); | ||
| 187 | + | ||
| 188 | + //屏幕共享 | ||
| 189 | + this.publishScreenShare = this._publishScreenShare.bind(this); | ||
| 190 | + this.stopPublishScreenShare = this._stopPublishScreenShare.bind(this); | ||
| 191 | + | ||
| 192 | + //videoApe | ||
| 193 | + //this.getVideoPlayPath = this._getVideoPlayPath.bind(this); | ||
| 194 | + this.getVideoPublishPath = this._getVideoPublishPath.bind(this); | ||
| 195 | + this.getVideoAllChannelInfo = this._getVideoAllChannelInfo.bind(this); | ||
| 196 | + this.publishVideo = this._publishVideo.bind(this); | ||
| 197 | + this.stopPublishVideo = this.unPublishVideo = this._stopPublishVideo.bind(this); | ||
| 198 | + this.sendVideoBroadcastMsg = this._sendVideoBroadcastMsg.bind(this); | ||
| 199 | + | ||
| 200 | + //audioApe | ||
| 201 | + //this.getAudioPlayPath = this._getPlayAudioPath.bind(this); | ||
| 202 | + this.getAudioPublishPath = this._getPublishAudioPath.bind(this); | ||
| 203 | + this.getAudioAllChannelInfo = this._getAudioAllChannelInfo.bind(this); | ||
| 204 | + this.publishAudio = this._publishAudio.bind(this); | ||
| 205 | + this.stopPublishAudio = this.unPublishAudio = this._stopPublishAudio.bind(this); | ||
| 206 | + this.sendAudioBroadcastMsg = this.sendAudioCommandMsg.bind(this); | ||
| 207 | + | ||
| 208 | + //whiteBoradApe | ||
| 209 | + this.sendInsertAnnotaion = this._sendInsertAnnotaion.bind(this); //添加标注 | ||
| 210 | + this.sendDeleteAllAnnotation = this._sendDeleteAllAnnotation.bind(this); //删除所有标注 | ||
| 211 | + this.sendDeleteCurPageAnnotation = this._sendDeleteCurPageAnnotation.bind(this); //删除当前页的所有标注 | ||
| 212 | + this.sendGotoPrev = this._sendGotoPrev.bind(this); //当前页撤销上一步 | ||
| 213 | + | ||
| 214 | + // CursorApe | ||
| 215 | + this.sendInsertCursor = this._sendInsertCursor.bind(this); //添加鼠标同步 | ||
| 216 | + | ||
| 217 | + //DocApe | ||
| 218 | + this.sendDocumentUpload = this._sendDocumentUpload.bind(this); //上传文档 | ||
| 219 | + this.sendDocumentSwitchDoc = this._sendDocumentSwitchDoc.bind(this); //切换文档 | ||
| 220 | + this.sendDocumentSwitchPage = this._sendDocumentSwitchPage.bind(this); //翻页 | ||
| 221 | + this.sendDocumentSwitchAnimation = this._sendDocumentSwitchAnimation.bind(this); //切换当前页码的动画步骤 | ||
| 222 | + this.sendDocumentDelete = this._sassDeleteDocument.bind(this); | ||
| 223 | + this.sendDocBroadcastMsg = this._sendDocBroadcastMsg.bind(this); | ||
| 224 | + //删除文档,先通过Sass删除,sass删除成功之后再同步mcu | ||
| 225 | + //this.sendDocumentDeleteAll= this._documentDeleteAll;//删除所有文档 | ||
| 226 | + this.sendDocumentCommand = this._sendDocumentCommand.bind(this); | ||
| 227 | + //操作文档(翻页、缩放、滚动...) | ||
| 228 | + this.getDocImageFullPath = this._getDocImageFullPath.bind(this); | ||
| 229 | + //获取文档图片的完整路径 | ||
| 230 | + this.getDocPDFFullPath = this._getDocPDFFullPath.bind(this); //获取文档的完整路径 | ||
| 231 | + this.getDocFullAddress = this._getDocFullAddress.bind(this); //获取文档资源地址 | ||
| 232 | + | ||
| 233 | + //媒体共享模块 | ||
| 234 | + this.mediaSharedUpload = this._sendMediaSharedUpload.bind(this); //上传 | ||
| 235 | + this.mediaSharedDelete = this._sassDeletMediaShare.bind(this); //删除,先通过Sass删除,删除成功之后才删除MCU的 | ||
| 236 | + | ||
| 237 | + this.mediaSharedPlay = this._sendMediaSharedPlay.bind(this); //播放 | ||
| 238 | + this.mediaSharedStop = this._sendMediaSharedStop.bind(this); //停止 | ||
| 239 | + this.mediaSharedUpdate = this._sendMediaSharedUpdate.bind(this); //更新媒体的状态 | ||
| 240 | + | ||
| 241 | + //音频共享模块 | ||
| 242 | + this.musicSharedUpload = this._sendMusicSharedUpload.bind(this); //上传 | ||
| 243 | + this.musicSharedDelete = this._sassDeletMusicShare.bind(this); //删除,先通过Sass删除,删除成功之后才删除MCU的 | ||
| 244 | + | ||
| 245 | + this.musicSharedPlay = this._sendMusicSharedPlay.bind(this); //Music播放 | ||
| 246 | + this.musicSharedStop = this._sendMusicSharedStop.bind(this); //Music停止 | ||
| 247 | + this.musicSharedUpdate = this._sendMusicSharedUpdate.bind(this); //Music更新媒体的状态 | ||
| 248 | + | ||
| 249 | + //答题卡 | ||
| 250 | + this.creatQuestion = this._creatQuestion.bind(this); | ||
| 251 | + this.getQuestion = this._getQuestion.bind(this); | ||
| 252 | + this.getQuestionResult = this._getQuestionResult.bind(this); | ||
| 253 | + this.sendAnswer = this._sendAnswer.bind(this); | ||
| 254 | + this.stopQuestion = this._stopQuestion.bind(this); | ||
| 255 | + | ||
| 256 | + this.setDeviceInfo = this._setDeviceInfo.bind(this); //设置设备信息(麦克风,摄像头等等.....) | ||
| 257 | + this.setMessageDelay = this._setMessageDelay.bind(this); //设置是否延迟消息 | ||
| 258 | + this.switchServer = this._switchMcuIpHandler.bind(this); //切换mcu服务器 | ||
| 259 | + this.switchMediaServer = this._switchMediaServer.bind(this); //手动切换ms服务器 | ||
| 260 | + this.setDebugInfo = this._setDebugInfo.bind(this); //设置debug信息 | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + _setDebugInfo(_data) { | ||
| 264 | + loger.log("设置debug信息-->", _data); | ||
| 265 | + if (_data) { | ||
| 266 | + Loger.setLogDebug(_data.isDebug); | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + //设置设备信息 | ||
| 271 | + _setDeviceInfo(_data) { | ||
| 272 | + loger.log("设置设备信息-->", _data); | ||
| 273 | + if (_data) { | ||
| 274 | + GlobalConfig.cameras = _data.cameras || []; | ||
| 275 | + GlobalConfig.microphones = _data.microphones || []; | ||
| 276 | + GlobalConfig.videoQuality = parseInt(_data.videoQuality); | ||
| 277 | + GlobalConfig.curVideoQuality = parseInt(_data.curVideoQuality); | ||
| 278 | + GlobalConfig.micGain = _data.micGain || 50; | ||
| 279 | + GlobalConfig.speakerVolume = _data.speakerVolume || 50; | ||
| 280 | + GlobalConfig.micCode = _data.micCode || 0; | ||
| 281 | + GlobalConfig.curCamera = _data.curCamera || ''; | ||
| 282 | + GlobalConfig.curMicrophone = _data.curMicrophone || ''; | ||
| 283 | + | ||
| 284 | + if (!GlobalConfig.curCamera && GlobalConfig.cameras.length > 0) { | ||
| 285 | + GlobalConfig.curCamera = GlobalConfig.cameras[0]; | ||
| 286 | + } | ||
| 287 | + if (!GlobalConfig.curMicrophone && GlobalConfig.microphones.length > 0) { | ||
| 288 | + GlobalConfig.curMicrophone = GlobalConfig.microphones[0]; | ||
| 289 | + } | ||
| 290 | + this._updateDeviceInfo(); | ||
| 291 | + } | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + //设置消息延迟 | ||
| 295 | + _setMessageDelay(_data) { | ||
| 296 | + loger.warn("延迟消息-->", _data); | ||
| 297 | + if (_data) { | ||
| 298 | + GlobalConfig.messageDelay = _data.messageDelay || false; | ||
| 299 | + } | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + //mcu异常监听 | ||
| 303 | + _mcuErrorHandler(_data, _option) { | ||
| 304 | + let option = _option || ""; | ||
| 305 | + let errorMessage = {"code": _data, "reson": MessageTypes.ErrorReson[_data] + " " + option}; | ||
| 306 | + this._emit(MessageTypes.ERROR_EVENT, errorMessage); | ||
| 307 | + loger.error("MCU_ERROR", errorMessage); | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + //获取当前的状态 | ||
| 311 | + _getMcuClientStatus() { | ||
| 312 | + return GlobalConfig.getCurrentStatus(); | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + //获取课堂信息 | ||
| 316 | + _getClassDetail() { | ||
| 317 | + return GlobalConfig.getClassDetail(); | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + //获取当前课堂的状态信息 | ||
| 321 | + _getClassStatusInfo() { | ||
| 322 | + return GlobalConfig.classStatusInfo; | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + //执行离开课堂断开连接的流程 | ||
| 326 | + _runClassExit(_type) { | ||
| 327 | + this._leaveClass(_type); | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + //当前的课堂状态信息发生改变,需要保存课堂状态到Sass | ||
| 331 | + _onClassStatusInfoChange(_param) { | ||
| 332 | + //如果MCU连接已经断开,不发送 | ||
| 333 | + if (GlobalConfig.getCurrentStatus().code != GlobalConfig.statusCode_2.code) { | ||
| 334 | + loger.warn("不能保存课堂状态", GlobalConfig.getCurrentStatus()); | ||
| 335 | + return; | ||
| 336 | + } | ||
| 337 | + this._sassSaveClassStatusInfo(_param); | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + //如果是第一次点击开始上课,需要创建录制时的文件名 | ||
| 341 | + _onClassRecordStart(_param) { | ||
| 342 | + if (GlobalConfig.getCurrentStatus().code != GlobalConfig.statusCode_2.code) { | ||
| 343 | + loger.warn("不能保存课堂状态", GlobalConfig.getCurrentStatus()); | ||
| 344 | + return; | ||
| 345 | + } | ||
| 346 | + if (_sass) { | ||
| 347 | + _sass.saveClassRecordContrlInfo(_param); | ||
| 348 | + } | ||
| 349 | + } | ||
| 350 | + | ||
| 351 | + //开启录制成功 | ||
| 352 | + _onClassRecordSuccess(_param) { | ||
| 353 | + clearTimeout(this.classRecordStatusUpdateTimer); | ||
| 354 | + let _this = this; | ||
| 355 | + this.classRecordStatusUpdateTimer = setTimeout(function () { | ||
| 356 | + clearTimeout(this.classRecordStatusUpdateTimer); | ||
| 357 | + _this.updaterRecordAllApeStatus(_param); | ||
| 358 | + }, 2000); | ||
| 359 | + | ||
| 360 | + } | ||
| 361 | + | ||
| 362 | + //录制状态发送改变,更新所有模块的当前数据发送到MCU | ||
| 363 | + updaterRecordAllApeStatus(_param) { | ||
| 364 | + //老师身份和非录制回放的时候执行,录制状态发送改变,需要更新当前的数据,否则已有的消息会录制不上 | ||
| 365 | + if (GlobalConfig.isHost && !GlobalConfig.isRecordPlayBack) { | ||
| 366 | + loger.warn('录制状态发送改变->更新所有模块的当前数据发送到MCU'); | ||
| 367 | + //目前录制的模块[文档模块、白板模块、视频模块(包含屏幕共享)、音频模块、媒体共享,聊天模块] | ||
| 368 | + if (_doc_ape) { | ||
| 369 | + _doc_ape.updaterRecordApeStatus(); | ||
| 370 | + } | ||
| 371 | + if (_whiteboard_ape) { | ||
| 372 | + _whiteboard_ape.updaterRecordApeStatus(); | ||
| 373 | + } | ||
| 374 | + if (_video_ape) { | ||
| 375 | + _video_ape.updaterRecordApeStatus(); | ||
| 376 | + } | ||
| 377 | + if (_audio_ape) { | ||
| 378 | + _audio_ape.updaterRecordApeStatus(); | ||
| 379 | + } | ||
| 380 | + if (_mediaShareApe) { | ||
| 381 | + _mediaShareApe.updaterRecordApeStatus(); | ||
| 382 | + } | ||
| 383 | + //聊天模块不需要更新 | ||
| 384 | + } | ||
| 385 | + } | ||
| 386 | + | ||
| 387 | + //有人员离开 | ||
| 388 | + _onClassDeleteRoster(_data) { | ||
| 389 | + | ||
| 390 | + } | ||
| 391 | + | ||
| 392 | + //当前课堂中视频或音频占用channel的nodeId ,在人员列表中不存在,这种情况是占用channel的人员掉线或离开的时候没有释放channel | ||
| 393 | + //的占用状态导致,对于这种情况,需要释放掉 | ||
| 394 | + _onClassNonentityRoster(_param) { | ||
| 395 | + if (GlobalConfig.isRecordPlayBack) { | ||
| 396 | + loger.warn("录制回放中,不处理") | ||
| 397 | + return; | ||
| 398 | + } | ||
| 399 | + | ||
| 400 | + if (_param == null || _param.nodeId == null) { | ||
| 401 | + loger.warn("onClassNonentityRoster.参数错误") | ||
| 402 | + return; | ||
| 403 | + } | ||
| 404 | + let data = {"nodeId": _param.nodeId}; | ||
| 405 | + if (_video_ape) { | ||
| 406 | + _video_ape.stopPublishVideo(data); | ||
| 407 | + | ||
| 408 | + //停止屏幕共享 | ||
| 409 | + if (GlobalConfig.nodeId == data.nodeId) { | ||
| 410 | + _video_ape.stopPublishScreenShare(data); | ||
| 411 | + } | ||
| 412 | + } | ||
| 413 | + if (_audio_ape) { | ||
| 414 | + _audio_ape.stopPublishAudio(data); | ||
| 415 | + } | ||
| 416 | + } | ||
| 417 | + | ||
| 418 | + //Sass | ||
| 419 | + //初始化 | ||
| 420 | + _init(_param) { | ||
| 421 | + //{"classId":"1653304953","portal":"112.126.80.182:80","userRole":"normal","userId":0,isH5:false} | ||
| 422 | + //判断传入的参数是否存在 | ||
| 423 | + if (_param == null || EngineUtils.isEmptyObject(_param)) { | ||
| 424 | + loger.error('初始化课堂失败->参数错误', _param); | ||
| 425 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_CLASS_INIT_PARAM); | ||
| 426 | + return; | ||
| 427 | + } | ||
| 428 | + //判断必要的参数字段值 | ||
| 429 | + if (_param.classId == null || isNaN(_param.classId) || _param.portal == null || _param.portal == "") { | ||
| 430 | + loger.error('初始化课堂失败->参数错误', _param); | ||
| 431 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_CLASS_INIT_PARAM); | ||
| 432 | + return; | ||
| 433 | + } | ||
| 434 | + loger.log('初始化课堂->', _param); | ||
| 435 | + | ||
| 436 | + //保存参数 | ||
| 437 | + GlobalConfig.isRecordPlayBack = false; //设置为非录制回放状态 | ||
| 438 | + GlobalConfig.classId = parseInt(_param.classId); | ||
| 439 | + GlobalConfig.portal = _param.portal; | ||
| 440 | + | ||
| 441 | + //H5处理 | ||
| 442 | + GlobalConfig.isH5 = _param.isH5 || false;//外部传入的参数,是否是H5 | ||
| 443 | + if (GlobalConfig.isH5 == true) { | ||
| 444 | + GlobalConfig.platform = "H5"; | ||
| 445 | + GlobalConfig.deviceType = 3//3是H5 | ||
| 446 | + loger.warn("设备类型是H5"); | ||
| 447 | + } | ||
| 448 | + | ||
| 449 | + //IOS 安卓处理,需要外部传入摄像头和麦克风信息 | ||
| 450 | + if (GlobalConfig.isMobile) { | ||
| 451 | + GlobalConfig.cameras = _param.cameras || []; | ||
| 452 | + GlobalConfig.microphones = _param.microphones || []; | ||
| 453 | + } | ||
| 454 | + | ||
| 455 | + //如果没有名字,随机起一个名字 | ||
| 456 | + GlobalConfig.userName = _param.userName || "user_" + (new Date().getTime() % 1000000); | ||
| 457 | + | ||
| 458 | + //如果没有userId或者为"0",随机生成 | ||
| 459 | + if (!GlobalConfig.userId || GlobalConfig.userId == "0") { | ||
| 460 | + GlobalConfig.userId = "user_" + (new Date().getTime() % 1000000); | ||
| 461 | + } | ||
| 462 | + //设置角色身份 | ||
| 463 | + GlobalConfig.userRole = _param.userRole || ApeConsts.normal; | ||
| 464 | + if (GlobalConfig.userRole != ApeConsts.host && | ||
| 465 | + GlobalConfig.userRole != ApeConsts.presenter && | ||
| 466 | + GlobalConfig.userRole != ApeConsts.assistant && | ||
| 467 | + GlobalConfig.userRole != ApeConsts.record && | ||
| 468 | + GlobalConfig.userRole != ApeConsts.invisible) { | ||
| 469 | + GlobalConfig.userRole = ApeConsts.normal; | ||
| 470 | + } | ||
| 471 | + //客户端决定是否延迟接收消息 | ||
| 472 | + GlobalConfig.messageDelay = _param.messageDelay || false; | ||
| 473 | + | ||
| 474 | + //最长允许录制的时间 | ||
| 475 | + if (_param.allowRecordMaxTime) { | ||
| 476 | + GlobalConfig.allowRecordMaxTime = parseInt(_param.allowRecordMaxTime); | ||
| 477 | + } | ||
| 478 | + | ||
| 479 | + //获取课堂校验信息 | ||
| 480 | + if (_sass) { | ||
| 481 | + _sass.getJoinParams(GlobalConfig.getClassInfo()); | ||
| 482 | + } | ||
| 483 | + } | ||
| 484 | + | ||
| 485 | + //外部请求加入课堂 | ||
| 486 | + _joinClass(_param) { | ||
| 487 | + if (_param == null || EngineUtils.isEmptyObject(_param)) { | ||
| 488 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_CLASS_JOIN_PARAM); | ||
| 489 | + loger.log('加入课堂失败->参数错误.', _param); | ||
| 490 | + return; | ||
| 491 | + } | ||
| 492 | + //判断userName | ||
| 493 | + if (_param.userName == null || _param.userName == "") { | ||
| 494 | + loger.log('加入课堂失败->参数错误->名字不能为空'); | ||
| 495 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_CLASS_JOIN_PARAM); | ||
| 496 | + return; | ||
| 497 | + } | ||
| 498 | + //{"userName":"名字","password":"","autoLogin":""} | ||
| 499 | + GlobalConfig.userName = _param.userName || GlobalConfig.userName; //以登陆时的名字为主,登陆之前可以修改名字 | ||
| 500 | + GlobalConfig.autoLogin = _param.autoLogin || ""; | ||
| 501 | + GlobalConfig.password = _param.password || ""; | ||
| 502 | + GlobalConfig.hasCamera = (typeof _param.hasCamera == "boolean") ? _param.hasCamera : false; | ||
| 503 | + GlobalConfig.hasMicrophone = (typeof _param.hasMicrophone == "boolean") ? _param.hasMicrophone : false; | ||
| 504 | + | ||
| 505 | + //loger.log("autoLoginMd5", GlobalConfig.classId, GlobalConfig.userId, GlobalConfig.userRole); | ||
| 506 | + let autoLoginMd5 = MD5("" + GlobalConfig.classId + GlobalConfig.userId + GlobalConfig.userRole); | ||
| 507 | + //loger.log("joinClass-GlobalConfig.autoLogin", GlobalConfig.autoLogin, "autoLoginMd5-", autoLoginMd5); | ||
| 508 | + if (GlobalConfig.autoLogin && autoLoginMd5 == GlobalConfig.autoLogin) { | ||
| 509 | + // MD5(classId+userId+userRole)==m | ||
| 510 | + //自动登录,跳过验证流程 | ||
| 511 | + loger.log("自动登录"); | ||
| 512 | + this._sassJoinSuccessHandler(); | ||
| 513 | + } else { | ||
| 514 | + //不能自动登录,开始校验 | ||
| 515 | + if (_sass) { | ||
| 516 | + _sass.passwordAndMd5Checking(GlobalConfig.getClassInfo()); | ||
| 517 | + } | ||
| 518 | + } | ||
| 519 | + } | ||
| 520 | + | ||
| 521 | + // 用classId向SASS平台获取入会验证信息成功 | ||
| 522 | + _sassInitSuccessHandler(_data) { | ||
| 523 | + //{"siteId":"h5test","passwordRequired":true,"md5":"de399d5540b3da2fbc1eb0a770d4fd66","code":0,"msType":1} | ||
| 524 | + //储存数据 | ||
| 525 | + GlobalConfig.md5 = _data.md5 || ""; //这个暂时用假数据,后台接口写完就有数据了 | ||
| 526 | + GlobalConfig.msType = _data.msType || 1; | ||
| 527 | + GlobalConfig.siteId = _data.siteId || ""; | ||
| 528 | + GlobalConfig.classType = _data.meetingType || ApeConsts.CLASS_TYPE_1; | ||
| 529 | + | ||
| 530 | + //host默认需要密码,Sass服务器只判断学生是否需要密码,没有判断老师的 | ||
| 531 | + GlobalConfig.passwordRequired = _data.passwordRequired || false; //md5验证的时候需要Sass返回的值,不能更改 | ||
| 532 | + loger.log('初始化课堂验证完成.'); | ||
| 533 | + | ||
| 534 | + //设置当前的课堂状态 | ||
| 535 | + GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_1); | ||
| 536 | + //返回给客户端初始化成功的数据 | ||
| 537 | + let initSuccessCallBackData = {}; | ||
| 538 | + initSuccessCallBackData.siteId = GlobalConfig.siteId; | ||
| 539 | + initSuccessCallBackData.classId = GlobalConfig.classId; | ||
| 540 | + initSuccessCallBackData.userRole = GlobalConfig.userRole; | ||
| 541 | + initSuccessCallBackData.userId = GlobalConfig.userId; | ||
| 542 | + initSuccessCallBackData.userName = GlobalConfig.userName; | ||
| 543 | + initSuccessCallBackData.classType = GlobalConfig.classType; | ||
| 544 | + | ||
| 545 | + //host默认需要密码,Sass服务器只判断学生是否需要密码,没有判断老师的 | ||
| 546 | + if (GlobalConfig.userRole == ApeConsts.host) { | ||
| 547 | + initSuccessCallBackData.passwordRequired = true; | ||
| 548 | + } else { | ||
| 549 | + initSuccessCallBackData.passwordRequired = GlobalConfig.passwordRequired; | ||
| 550 | + } | ||
| 551 | + | ||
| 552 | + this._emit(MessageTypes.CLASS_INIT_SUCCESS, initSuccessCallBackData); | ||
| 553 | + } | ||
| 554 | + | ||
| 555 | + // 通过SASS平台验证(密码和MD5) | ||
| 556 | + _sassJoinSuccessHandler(_data) { | ||
| 557 | + //获取课堂最完整的数据 | ||
| 558 | + if (_sass) { | ||
| 559 | + _sass.getClassParam(); | ||
| 560 | + } | ||
| 561 | + } | ||
| 562 | + | ||
| 563 | + //加载本地Server.json文件,UserIp获取ip信息,选点 | ||
| 564 | + loadServerJsonAndgetUserIpInfo() { | ||
| 565 | + let _this = this; | ||
| 566 | + if (_ipManager) { | ||
| 567 | + //先加载本地Server.json文件,然后获取userIp新 | ||
| 568 | + _ipManager.loadServerJosn(function (_data) { | ||
| 569 | + _ipManager.getUserIpInfo("", GlobalConfig.userIp, _this._getUserIpCallbackHandler.bind(_this), 2000); | ||
| 570 | + }) | ||
| 571 | + } | ||
| 572 | + } | ||
| 573 | + | ||
| 574 | + //本地JOSN加载完成-获取IP信息完成 | ||
| 575 | + _getUserIpCallbackHandler(_data) { | ||
| 576 | + //获取IP信息,返回一次就不再处理 | ||
| 577 | + if (this.isGetUserIpCallback) { | ||
| 578 | + return; | ||
| 579 | + } | ||
| 580 | + this.isGetUserIpCallback = true; | ||
| 581 | + if (_data && _data.ret == "ok") { | ||
| 582 | + GlobalConfig.country = _data.country; //国家 | ||
| 583 | + GlobalConfig.city = _data.city; //城市 | ||
| 584 | + GlobalConfig.province = _data.province; //服务商 | ||
| 585 | + GlobalConfig.isp = _data.isp; //服务商 | ||
| 586 | + } | ||
| 587 | + | ||
| 588 | + //根据用户的userIp信息从sever.json和Sass中选择最终mcu和推流拉流数据列表 | ||
| 589 | + this._choiceMcuAndMsListFromServerAndSass(); | ||
| 590 | + //获取MCU和MS 推流拉流、录制回放的默认地址 | ||
| 591 | + this.getMcuAndMsDefaultServerIp(); | ||
| 592 | + | ||
| 593 | + loger.warn("加入课堂之前->开始测速->选择默认服务"); | ||
| 594 | + //加入课堂之前开始第一次选点 | ||
| 595 | + let _this = this; | ||
| 596 | + | ||
| 597 | + | ||
| 598 | + //推流地址测速 | ||
| 599 | + this._getFastestIpFromServer(GlobalConfig.msListFinal, | ||
| 600 | + function (_data) { | ||
| 601 | + loger.log("推流地址测速->", _data); | ||
| 602 | + if (_data && _data.ip) { | ||
| 603 | + GlobalConfig.MS_PUBLISH_IP = _data.ip || ""; | ||
| 604 | + GlobalConfig.MS_PUBLISH_PORT = _data.port || ""; | ||
| 605 | + } | ||
| 606 | + _this.isGetFastestMsCallback = true; | ||
| 607 | + _this._startConnectMCU(); | ||
| 608 | + }); | ||
| 609 | + | ||
| 610 | + //录制回放HLS拉流地址测速 | ||
| 611 | + this._getFastestIpFromServer(GlobalConfig.rsPullListFinal, function (_data) { | ||
| 612 | + loger.log("录制回放HLS拉流地址测速->", _data); | ||
| 613 | + if (_data && _data.ip) { | ||
| 614 | + GlobalConfig.RS_RECORD_PLAY_IP = _data.ip || ""; | ||
| 615 | + GlobalConfig.RS_RECORD_PLAY_PORT = _data.port || ""; | ||
| 616 | + } | ||
| 617 | + _this.isGetFastestRsCallback = true; | ||
| 618 | + _this._startConnectMCU(); | ||
| 619 | + }); | ||
| 620 | + | ||
| 621 | + //HLS和RTMP不参与测速 | ||
| 622 | +/* | ||
| 623 | + | ||
| 624 | + //RTMP拉流地址测速 | ||
| 625 | + this._getFastestIpFromServer(GlobalConfig.rtmpPullListFinal, function (_data) { | ||
| 626 | + loger.log("RTMP拉流地址测速->", _data); | ||
| 627 | + if (_data && _data.ip) { | ||
| 628 | + GlobalConfig.MS_PLAY_RTMP_IP = _data.ip || ""; | ||
| 629 | + GlobalConfig.MS_PLAY_RTMP_PORT = _data.port || ""; | ||
| 630 | + } | ||
| 631 | + _this.isGetFastestRtmpPullCallback = true; | ||
| 632 | + _this._startConnectMCU(); | ||
| 633 | + }); | ||
| 634 | + | ||
| 635 | + //HLS拉流地址测速 | ||
| 636 | + this._getFastestIpFromServer(GlobalConfig.hlsListFinal, function (_data) { | ||
| 637 | + loger.log("HLS拉流地址测速->", _data); | ||
| 638 | + if (_data && _data.ip) { | ||
| 639 | + GlobalConfig.MS_PLAY_HLS_IP = _data.ip || ""; | ||
| 640 | + GlobalConfig.MS_PLAY_HLS_PORT = _data.port || ""; | ||
| 641 | + } | ||
| 642 | + _this.isGetFastestHlsPullCallback = true; | ||
| 643 | + _this._startConnectMCU(); | ||
| 644 | + }); | ||
| 645 | +*/ | ||
| 646 | + | ||
| 647 | + //MCU测速 | ||
| 648 | + this._getFastestMcuServer(function (_data) { | ||
| 649 | + loger.log("MCU测速->", _data); | ||
| 650 | + if (_data && _data.ip) { | ||
| 651 | + GlobalConfig.MCUServerIP = _data.ip || ""; | ||
| 652 | + GlobalConfig.MCUServerPort = _data.port || ""; | ||
| 653 | + } | ||
| 654 | + _this.isGetFastestMcuCallback = true; | ||
| 655 | + _this._startConnectMCU(); | ||
| 656 | + }); | ||
| 657 | + } | ||
| 658 | + | ||
| 659 | + | ||
| 660 | + /* //本地JOSN加载完成-获取IP信息完成 | ||
| 661 | + _getUserIpCallbackHandler(_data) { | ||
| 662 | + //获取IP信息,返回一次就不再处理 | ||
| 663 | + if (this.isGetUserIpCallback) { | ||
| 664 | + return; | ||
| 665 | + } | ||
| 666 | + this.isGetUserIpCallback = true; | ||
| 667 | + if (_data && _data.ret == "ok") { | ||
| 668 | + GlobalConfig.country = _data.country; //国家 | ||
| 669 | + GlobalConfig.city = _data.city; //城市 | ||
| 670 | + GlobalConfig.province = _data.province; //服务商 | ||
| 671 | + GlobalConfig.isp = _data.isp; //服务商 | ||
| 672 | + } | ||
| 673 | + | ||
| 674 | + //合并MCU 、MS的列表 | ||
| 675 | + this._choiceMcuAndMsList(); | ||
| 676 | + | ||
| 677 | + //开始选点 | ||
| 678 | + let _this = this; | ||
| 679 | + | ||
| 680 | + //有一些站点不需要进行MS选点,需要先检查一下 | ||
| 681 | + if (GlobalConfig.siteId_letv == GlobalConfig.siteId) { | ||
| 682 | + //MS不需要选点 | ||
| 683 | + loger.log("MS不需要选点->siteId->", GlobalConfig.siteId); | ||
| 684 | + _this.isGetFastestMcuCallback = true; | ||
| 685 | + _this._startConnectMCU(); | ||
| 686 | + } else { | ||
| 687 | + this._getFastestMsServer(function (_data) { | ||
| 688 | + loger.log("MS选点结束->", _data); | ||
| 689 | + if (_data && _data.ip) { | ||
| 690 | + GlobalConfig.MS_PUBLISH_IP = _data.ip || ""; | ||
| 691 | + GlobalConfig.MS_PUBLISH_PORT = _data.port || ""; | ||
| 692 | + } | ||
| 693 | + loger.log("当前使用的MS->", GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT); | ||
| 694 | + _this.isGetFastestMcuCallback = true; | ||
| 695 | + _this._startConnectMCU(); | ||
| 696 | + }); | ||
| 697 | + } | ||
| 698 | + | ||
| 699 | + this._getFastestMcuServer(function (_data) { | ||
| 700 | + loger.log("MCU选点结束->", _data); | ||
| 701 | + if (_data && _data.ip) { | ||
| 702 | + GlobalConfig.MCUServerIP = _data.ip || ""; | ||
| 703 | + GlobalConfig.MCUServerPort = _data.port || ""; | ||
| 704 | + } | ||
| 705 | + loger.log("当前使用的MCU->", GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); | ||
| 706 | + _this.isGetFastestMsCallback = true; | ||
| 707 | + _this._startConnectMCU(); | ||
| 708 | + }); | ||
| 709 | + }*/ | ||
| 710 | + | ||
| 711 | + //开始连接MCU(所有服务地址测试完成之后开始连接) | ||
| 712 | + _startConnectMCU() { | ||
| 713 | + if (this.isGetFastestMcuCallback && | ||
| 714 | + this.isGetFastestMsCallback && | ||
| 715 | + this.isGetFastestRtmpPullCallback && | ||
| 716 | + this.isGetFastestHlsPullCallback && | ||
| 717 | + this.isGetFastestRsCallback) { | ||
| 718 | + //mcu完成 | ||
| 719 | + //ms推流测速完成 | ||
| 720 | + //rtmp拉流测速完成 | ||
| 721 | + //hls拉流测速完成 | ||
| 722 | + //hls录制回放拉流测速完成 | ||
| 723 | + this._joinMCU(); | ||
| 724 | + } | ||
| 725 | + } | ||
| 726 | + | ||
| 727 | + //从Sever和Sass中选择的mcu、ms列表,如果server.json中存在就不使用Sass | ||
| 728 | + _choiceMcuAndMsListFromServerAndSass() { | ||
| 729 | + //1.根据user信息获取服务器列表 | ||
| 730 | + if (_ipManager) { | ||
| 731 | + GlobalConfig.mcuListFromServer = _ipManager.getServerListForUserInfo( | ||
| 732 | + "MCU", | ||
| 733 | + GlobalConfig.country, | ||
| 734 | + GlobalConfig.province, | ||
| 735 | + GlobalConfig.city, | ||
| 736 | + GlobalConfig.isp, | ||
| 737 | + Server.serverList); | ||
| 738 | + | ||
| 739 | + GlobalConfig.msListFromServer = _ipManager.getServerListForUserInfo( | ||
| 740 | + "MS", | ||
| 741 | + GlobalConfig.country, | ||
| 742 | + GlobalConfig.province, | ||
| 743 | + GlobalConfig.city, | ||
| 744 | + GlobalConfig.isp, | ||
| 745 | + Server.serverList); | ||
| 746 | + | ||
| 747 | + GlobalConfig.rtmpPullListFromServer = _ipManager.getServerListForUserInfo( | ||
| 748 | + "RTMP_PULL", | ||
| 749 | + GlobalConfig.country, | ||
| 750 | + GlobalConfig.province, | ||
| 751 | + GlobalConfig.city, | ||
| 752 | + GlobalConfig.isp, | ||
| 753 | + Server.serverList); | ||
| 754 | + | ||
| 755 | + GlobalConfig.rsPullListFromServer = _ipManager.getServerListForUserInfo( | ||
| 756 | + "RS_PULL", | ||
| 757 | + GlobalConfig.country, | ||
| 758 | + GlobalConfig.province, | ||
| 759 | + GlobalConfig.city, | ||
| 760 | + GlobalConfig.isp, | ||
| 761 | + Server.serverList); | ||
| 762 | + | ||
| 763 | + GlobalConfig.hlsPullListFromServer = _ipManager.getServerListForUserInfo( | ||
| 764 | + "HLS_PULL", | ||
| 765 | + GlobalConfig.country, | ||
| 766 | + GlobalConfig.province, | ||
| 767 | + GlobalConfig.city, | ||
| 768 | + GlobalConfig.isp, | ||
| 769 | + Server.serverList); | ||
| 770 | + } | ||
| 771 | + | ||
| 772 | + loger.warn("Server中获取的服务器信息;") | ||
| 773 | + loger.warn(" GlobalConfig.mcuListFromServer", GlobalConfig.mcuListFromServer); | ||
| 774 | + loger.warn(" GlobalConfig.msListFromServer", GlobalConfig.msListFromServer); | ||
| 775 | + loger.warn(" GlobalConfig.rtmpPullListFromServer", GlobalConfig.rtmpPullListFromServer); | ||
| 776 | + loger.warn(" GlobalConfig.hlsPullListFromServer", GlobalConfig.hlsPullListFromServer); | ||
| 777 | + loger.warn(" GlobalConfig.rsPullListFromServer", GlobalConfig.rsPullListFromServer); | ||
| 778 | + | ||
| 779 | + | ||
| 780 | + //********选择最终使用的MCU、MS 和拉流列表******** | ||
| 781 | + //****优先使用server.json中的数据,如果没有再使用Sass中的数据**** | ||
| 782 | + | ||
| 783 | + //MCU | ||
| 784 | + GlobalConfig.mcuListFinal = []; | ||
| 785 | + if (GlobalConfig.mcuListFromServer.length > 0) { | ||
| 786 | + //使用server中的MCU数据 | ||
| 787 | + GlobalConfig.mcuListFinal = GlobalConfig.mcuListFromServer; | ||
| 788 | + } else { | ||
| 789 | + //使用Sass中的数据 | ||
| 790 | + GlobalConfig.mcuListFinal = GlobalConfig.mcuList; | ||
| 791 | + } | ||
| 792 | + | ||
| 793 | + //MS推流 | ||
| 794 | + GlobalConfig.msListFinal = [] | ||
| 795 | + if (GlobalConfig.msListFromServer.length > 0) { | ||
| 796 | + GlobalConfig.msListFinal = GlobalConfig.msListFromServer; | ||
| 797 | + } else { | ||
| 798 | + GlobalConfig.msListFinal = GlobalConfig.msList; | ||
| 799 | + } | ||
| 800 | + | ||
| 801 | + //RS录制回放HLS拉流 | ||
| 802 | + GlobalConfig.rsPullListFinal = [] | ||
| 803 | + if (GlobalConfig.msListFromServer.length > 0) { | ||
| 804 | + GlobalConfig.rsPullListFinal = GlobalConfig.rsPullListFromServer; | ||
| 805 | + } else { | ||
| 806 | + GlobalConfig.rsPullListFinal = GlobalConfig.rsList; | ||
| 807 | + } | ||
| 808 | + | ||
| 809 | + //RTMP拉流 | ||
| 810 | + GlobalConfig.rtmpPullListFinal = []; | ||
| 811 | + if (GlobalConfig.rtmpPullListFromServer.length > 0) { | ||
| 812 | + GlobalConfig.rtmpPullListFinal = GlobalConfig.rtmpPullListFromServer; | ||
| 813 | + } else { | ||
| 814 | + GlobalConfig.rtmpPullListFinal = GlobalConfig.rtmpPullList; | ||
| 815 | + } | ||
| 816 | + | ||
| 817 | + //HLS拉流流 | ||
| 818 | + GlobalConfig.hlsPullListFinal = []; | ||
| 819 | + if (GlobalConfig.hlsPullListFromServer.length > 0) { | ||
| 820 | + GlobalConfig.hlsPullListFinal = GlobalConfig.hlsPullListFromServer; | ||
| 821 | + } else { | ||
| 822 | + GlobalConfig.hlsPullListFinal = GlobalConfig.hlsPullList; | ||
| 823 | + } | ||
| 824 | + | ||
| 825 | + //拉流地址列表的特殊处理, | ||
| 826 | + // 1.如果RTMP拉流地址没有配置,就默认使用MS推流地址列表 | ||
| 827 | + if (!GlobalConfig.rtmpPullListFinal || GlobalConfig.rtmpPullListFinal.length < 1) { | ||
| 828 | + GlobalConfig.rtmpPullListFinal = GlobalConfig.msListFinal; | ||
| 829 | + } | ||
| 830 | + // 2.如果HLS拉流地址没有配置,就默认使用录制回放RS拉流地址列表中的数据 | ||
| 831 | + if (!GlobalConfig.hlsPullListFinal || GlobalConfig.hlsPullListFinal.length < 1) { | ||
| 832 | + GlobalConfig.hlsPullListFinal = GlobalConfig.rsPullListFinal; | ||
| 833 | + ; | ||
| 834 | + } | ||
| 835 | + | ||
| 836 | + loger.warn("课堂最终使用的服务列表->"); | ||
| 837 | + loger.warn(" GlobalConfig.mcuListFinal", GlobalConfig.mcuListFinal); | ||
| 838 | + loger.warn(" GlobalConfig.msListFinal", GlobalConfig.msListFinal); | ||
| 839 | + loger.warn(" GlobalConfig.rtmpPullListFinal", GlobalConfig.rtmpPullListFinal); | ||
| 840 | + loger.warn(" GlobalConfig.hlsListFinal", GlobalConfig.hlsPullListFinal); | ||
| 841 | + loger.warn(" GlobalConfig.rsListFinal", GlobalConfig.rsPullListFinal); | ||
| 842 | + | ||
| 843 | + } | ||
| 844 | + | ||
| 845 | + //开始测速 | ||
| 846 | + _getFastestIpFromServer(_dataArr, _callback) { | ||
| 847 | + if (_ipManager) { | ||
| 848 | + _ipManager.testFastestIpFromServer(_dataArr, _callback); | ||
| 849 | + } else { | ||
| 850 | + if (_callback) { | ||
| 851 | + _callback({'ip': ""}); | ||
| 852 | + } | ||
| 853 | + } | ||
| 854 | + } | ||
| 855 | + | ||
| 856 | + //开始MCU选点操作 | ||
| 857 | + _getFastestMcuServer(_callback) { | ||
| 858 | + if (_ipManager) { | ||
| 859 | + _ipManager.getFastestMcuServer(GlobalConfig.mcuListFinal, _callback); | ||
| 860 | + } else { | ||
| 861 | + if (_callback) { | ||
| 862 | + _callback({'ip': ""}); | ||
| 863 | + } | ||
| 864 | + } | ||
| 865 | + } | ||
| 866 | + | ||
| 867 | + //开始MS选点操作 | ||
| 868 | + _getFastestMsServer(_callback) { | ||
| 869 | + if (_ipManager) { | ||
| 870 | + _ipManager.getFastestMsServer(GlobalConfig.msListFinal, _callback); | ||
| 871 | + } else { | ||
| 872 | + if (_callback) { | ||
| 873 | + _callback({ip: ""}); | ||
| 874 | + } | ||
| 875 | + } | ||
| 876 | + } | ||
| 877 | + | ||
| 878 | + //开始MS-PULL选点操作 | ||
| 879 | + _getFastestRtmpPullServer(_callback) { | ||
| 880 | + if (_ipManager) { | ||
| 881 | + _ipManager.getFastestMsServer(GlobalConfig.rtmpPullListFinal, _callback); | ||
| 882 | + } else { | ||
| 883 | + if (_callback) { | ||
| 884 | + _callback({ip: ""}); | ||
| 885 | + } | ||
| 886 | + } | ||
| 887 | + } | ||
| 888 | + | ||
| 889 | + //开始MS-HLS选点操作 | ||
| 890 | + _getFastestHlsServer(_callback) { | ||
| 891 | + if (_ipManager) { | ||
| 892 | + _ipManager.getFastestMsServer(GlobalConfig.rtmpPullListFinal, _callback); | ||
| 893 | + } else { | ||
| 894 | + if (_callback) { | ||
| 895 | + _callback({ip: ""}); | ||
| 896 | + } | ||
| 897 | + } | ||
| 898 | + } | ||
| 899 | + | ||
| 900 | + //保存课堂状态信息 | ||
| 901 | + _sassSaveClassStatusInfo(_param) { | ||
| 902 | + //{isForce:true} isForce->是否强制提交(true为是) | ||
| 903 | + //这个是特殊权限 | ||
| 904 | + let isForce = false; | ||
| 905 | + if (_param && _param.isForce == true) { | ||
| 906 | + isForce = true; | ||
| 907 | + } | ||
| 908 | + | ||
| 909 | + if (GlobalConfig.isHost || isForce) { | ||
| 910 | + //只有加入课堂之后才能保存数据 | ||
| 911 | + if (GlobalConfig.getCurrentStatus().code == GlobalConfig.statusCode_2.code) { | ||
| 912 | + //POST 保存数据 | ||
| 913 | + _sass.saveClassStatusInfo({"classStatusInfo": GlobalConfig.classStatusInfo}); //保存课堂状态信息 | ||
| 914 | + } else { | ||
| 915 | + loger.error("不能保存课堂数据", GlobalConfig.getCurrentStatus()); | ||
| 916 | + } | ||
| 917 | + } else { | ||
| 918 | + loger.log("没有保存课堂状态信息的权限->身份", GlobalConfig.userRole); | ||
| 919 | + } | ||
| 920 | + } | ||
| 921 | + | ||
| 922 | + //保存会态信息成功 | ||
| 923 | + _sassSaveClassStatusInfoSuccessHandler(_data) { | ||
| 924 | + loger.log('保存课堂状态信息成功.'); | ||
| 925 | + loger.log(_data); | ||
| 926 | + } | ||
| 927 | + | ||
| 928 | + _sassSaveClassRecordInfoSuccessHandler(_data) { | ||
| 929 | + loger.log('保存课堂录制信息成功.'); | ||
| 930 | + loger.log(_data); | ||
| 931 | + } | ||
| 932 | + | ||
| 933 | + //Sass校验流程结束之后,开始加入MCU | ||
| 934 | + _joinMCU() { | ||
| 935 | + loger.log('加入课堂->.'); | ||
| 936 | + loger.warn("最终使用课堂服务信息->"); | ||
| 937 | + loger.warn('MCU服务器地址->mcu->', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); | ||
| 938 | + loger.warn('推流地址->MS->', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT); | ||
| 939 | + loger.warn('RTMP拉流地址->RTMP->', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT); | ||
| 940 | + loger.warn('HLS拉流地址->HLS->', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT); | ||
| 941 | + loger.warn('HLS录制回放拉流地址->HLS->', GlobalConfig.RS_RECORD_PLAY_IP, GlobalConfig.RS_RECORD_PLAY_PORT); | ||
| 942 | + | ||
| 943 | + if (_mcu) { | ||
| 944 | + _mcu.joinMCU(GlobalConfig.getClassInfo()); | ||
| 945 | + } | ||
| 946 | + } | ||
| 947 | + | ||
| 948 | + _switchMcuIp() { | ||
| 949 | + loger.log('切换MCU IP->.'); | ||
| 950 | + if (_mcu) { | ||
| 951 | + _mcu.switchMCUIp(GlobalConfig.getClassInfo()); | ||
| 952 | + } | ||
| 953 | + } | ||
| 954 | + | ||
| 955 | + // MCU 课堂成功 | ||
| 956 | + _mcuJoinMCUClassSuccessHandler(_data) { | ||
| 957 | + //loger.log('MCU 课堂成功.'); | ||
| 958 | + GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_2); | ||
| 959 | + GlobalConfig.classJoinSuccess = true; | ||
| 960 | + | ||
| 961 | + GlobalConfig.screenWidth = window.screen.width; | ||
| 962 | + GlobalConfig.screenHeight = window.screen.height; | ||
| 963 | + | ||
| 964 | + //返回给客户端初始化成功的数据 | ||
| 965 | + let joinClassSuccessCallBackData = {}; | ||
| 966 | + | ||
| 967 | + joinClassSuccessCallBackData.isRecordPlayBack = GlobalConfig.isRecordPlayBack; | ||
| 968 | + | ||
| 969 | + joinClassSuccessCallBackData.DOCServerIP = GlobalConfig.DOCServerIP; | ||
| 970 | + joinClassSuccessCallBackData.DOCServerPort = GlobalConfig.DOCServerPort; | ||
| 971 | + | ||
| 972 | + joinClassSuccessCallBackData.classStatus = GlobalConfig.classStatus; | ||
| 973 | + joinClassSuccessCallBackData.classId = GlobalConfig.classId; | ||
| 974 | + joinClassSuccessCallBackData.className = GlobalConfig.className; | ||
| 975 | + joinClassSuccessCallBackData.h5Module = GlobalConfig.h5Module; | ||
| 976 | + joinClassSuccessCallBackData.isHost = GlobalConfig.isHost; | ||
| 977 | + joinClassSuccessCallBackData.maxAudioChannels = GlobalConfig.maxAudioChannels; | ||
| 978 | + joinClassSuccessCallBackData.maxVideoChannels = GlobalConfig.maxVideoChannels; | ||
| 979 | + joinClassSuccessCallBackData.maxMediaChannels = GlobalConfig.maxMediaChannels; | ||
| 980 | + joinClassSuccessCallBackData.mcuDelay = GlobalConfig.mcuDelay; | ||
| 981 | + | ||
| 982 | + joinClassSuccessCallBackData.msType = GlobalConfig.msType; | ||
| 983 | + joinClassSuccessCallBackData.nodeId = GlobalConfig.nodeId; | ||
| 984 | + joinClassSuccessCallBackData.password = GlobalConfig.password; | ||
| 985 | + joinClassSuccessCallBackData.passwordRequired = GlobalConfig.passwordRequired; // 老师的默认是true | ||
| 986 | + //GlobalConfig.passwordRequired 老师的默认是true | ||
| 987 | + //GlobalConfig.portal=_data.portal; | ||
| 988 | + joinClassSuccessCallBackData.role = GlobalConfig.role; | ||
| 989 | + joinClassSuccessCallBackData.siteId = GlobalConfig.siteId; | ||
| 990 | + joinClassSuccessCallBackData.topNodeID = GlobalConfig.topNodeID; | ||
| 991 | + joinClassSuccessCallBackData.userId = GlobalConfig.userId; | ||
| 992 | + joinClassSuccessCallBackData.userName = GlobalConfig.userName; | ||
| 993 | + joinClassSuccessCallBackData.userRole = GlobalConfig.userRole; | ||
| 994 | + joinClassSuccessCallBackData.userType = GlobalConfig.userType; | ||
| 995 | + | ||
| 996 | + joinClassSuccessCallBackData.siteId = GlobalConfig.siteId; | ||
| 997 | + joinClassSuccessCallBackData.classId = GlobalConfig.classId; | ||
| 998 | + joinClassSuccessCallBackData.userRole = GlobalConfig.userRole; | ||
| 999 | + joinClassSuccessCallBackData.userId = GlobalConfig.userId; | ||
| 1000 | + joinClassSuccessCallBackData.passwordRequired = GlobalConfig.passwordRequired; | ||
| 1001 | + joinClassSuccessCallBackData.classType = GlobalConfig.classType || ApeConsts.CLASS_TYPE_1; | ||
| 1002 | + | ||
| 1003 | + joinClassSuccessCallBackData.country = GlobalConfig.country; //国家 | ||
| 1004 | + joinClassSuccessCallBackData.city = GlobalConfig.city; //城市 | ||
| 1005 | + joinClassSuccessCallBackData.province = GlobalConfig.province; //服务商 | ||
| 1006 | + joinClassSuccessCallBackData.isp = GlobalConfig.isp; //服务商 | ||
| 1007 | + | ||
| 1008 | + joinClassSuccessCallBackData.classTimestamp = GlobalConfig.classTimestamp; //课堂进行的累积时间 | ||
| 1009 | + joinClassSuccessCallBackData.recordTimestamp = GlobalConfig.recordTimestamp; //课堂录制的累积时间 | ||
| 1010 | + joinClassSuccessCallBackData.recordPlaybackMaxTime = GlobalConfig.recordPlaybackMaxTime; //录制回放的总时间 | ||
| 1011 | + | ||
| 1012 | + joinClassSuccessCallBackData.fps = GlobalConfig.fps; | ||
| 1013 | + joinClassSuccessCallBackData.gop = GlobalConfig.gop; | ||
| 1014 | + joinClassSuccessCallBackData.videoQuality = GlobalConfig.videoQuality; | ||
| 1015 | + | ||
| 1016 | + joinClassSuccessCallBackData.ssTunnelAppURL = GlobalConfig.ssTunnelAppURL; | ||
| 1017 | + joinClassSuccessCallBackData.currentSceneTableId = GlobalConfig.currentSceneTableId; //文档区域的模块显示 | ||
| 1018 | + joinClassSuccessCallBackData.serverAndLoacTimeDistanc = GlobalConfig.serverAndLoacTimeDistanc; | ||
| 1019 | + | ||
| 1020 | + joinClassSuccessCallBackData.deviceType = GlobalConfig.deviceType; | ||
| 1021 | + joinClassSuccessCallBackData.language = GlobalConfig.language; | ||
| 1022 | + joinClassSuccessCallBackData.explorer = GlobalConfig.explorer; | ||
| 1023 | + joinClassSuccessCallBackData.explorerVersion = GlobalConfig.explorerVersion; | ||
| 1024 | + joinClassSuccessCallBackData.os = GlobalConfig.os; | ||
| 1025 | + | ||
| 1026 | + loger.log('加入课堂成功->'); | ||
| 1027 | + loger.log(joinClassSuccessCallBackData); | ||
| 1028 | + | ||
| 1029 | + //加入课堂成功,广播消息 | ||
| 1030 | + this._emit(MessageTypes.CLASS_JOIN_SUCCESS, joinClassSuccessCallBackData); | ||
| 1031 | + } | ||
| 1032 | + | ||
| 1033 | + //切换MCU ->_param->{reConnect:false} //reConnect(是否立即替换当前的ip并且重新连接) | ||
| 1034 | + _switchMcuIpHandler(_param) { | ||
| 1035 | + if (GlobalConfig.isRecordPlayBack) { | ||
| 1036 | + loger.log('录制回放->不进行MCU动态选点'); | ||
| 1037 | + return; | ||
| 1038 | + } | ||
| 1039 | + loger.log('MCU->动态选点'); | ||
| 1040 | + let _this = this; | ||
| 1041 | + this._getFastestMcuServer(function (_data) { | ||
| 1042 | + loger.log("MCU选点结束->", _data); | ||
| 1043 | + //记录当前的IP地址,选点结束后需要判断一下是否是新的IP; | ||
| 1044 | + let oldIp = GlobalConfig.MCUServerIP; | ||
| 1045 | + | ||
| 1046 | + if (_data && _data.ip) { | ||
| 1047 | + GlobalConfig.MCUServerIP = _data.ip || ""; | ||
| 1048 | + GlobalConfig.MCUServerPort = _data.port || ""; | ||
| 1049 | + } else { | ||
| 1050 | + //随机选择一个 | ||
| 1051 | + if (GlobalConfig.mcuList && GlobalConfig.mcuList.length > 0) { | ||
| 1052 | + let index = parseInt(Math.random() * GlobalConfig.mcuList.length); | ||
| 1053 | + GlobalConfig.MCUServerIP = GlobalConfig.mcuList[index].ip || ""; | ||
| 1054 | + GlobalConfig.MCUServerPort = GlobalConfig.mcuList[index].port || ""; | ||
| 1055 | + } | ||
| 1056 | + } | ||
| 1057 | + if (oldIp && oldIp != GlobalConfig.MCUServerIP) { | ||
| 1058 | + loger.log('MCU->最新地址->', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); | ||
| 1059 | + //判断是否需要主动断开当前的连接然后重连新的服务器 | ||
| 1060 | + if (_param && _param.reConnect == true) { | ||
| 1061 | + loger.log('MCU->切换到最新的IP->', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); | ||
| 1062 | + _this._startConnectMCU(); | ||
| 1063 | + } else { | ||
| 1064 | + //不需要断开当前的连接,更改ip即可 | ||
| 1065 | + _this._switchMcuIp(); | ||
| 1066 | + } | ||
| 1067 | + } else { | ||
| 1068 | + //如果选点结束后获得的ip和当前的IP相同,不需要切换 | ||
| 1069 | + loger.log('MCU不需要切换->之前的IP->', oldIp, "新的IP->", GlobalConfig.MCUServerIP); | ||
| 1070 | + } | ||
| 1071 | + }); | ||
| 1072 | + } | ||
| 1073 | + | ||
| 1074 | + //课堂状态发生改变,需要停止当前的所有推流 | ||
| 1075 | + _stopAllMediaPublishHandler(_data) { | ||
| 1076 | + loger.log('课堂状态发生改变,需要停止当前的所有推流'); | ||
| 1077 | + this._emit(MessageTypes.MEDIA_STOP_PUBLISH); | ||
| 1078 | + } | ||
| 1079 | + | ||
| 1080 | + //手动切换MS -> {ip;"xxx.xx.xx","port":"xxxx"} | ||
| 1081 | + _switchMediaServer(_param) { | ||
| 1082 | + if (GlobalConfig.isRecordPlayBack) { | ||
| 1083 | + //录制回放不做操作 | ||
| 1084 | + loger.warn('录制回放->不能手动切换MS'); | ||
| 1085 | + return; | ||
| 1086 | + } | ||
| 1087 | + if (_param && _param.ip) { | ||
| 1088 | + GlobalConfig.MS_PUBLISH_IP = _param.ip || ""; | ||
| 1089 | + GlobalConfig.MS_PUBLISH_PORT = _param.port || ""; | ||
| 1090 | + } | ||
| 1091 | + loger.warn('手动切换MS->', GlobalConfig.MS_PUBLISH_IP + ":" + GlobalConfig.MS_PUBLISH_PORT); | ||
| 1092 | + //更换完用户当前的MS地址,需要更新用户数据 | ||
| 1093 | + if (_confer_ape) { | ||
| 1094 | + _confer_ape.updateUserInfo(); | ||
| 1095 | + } | ||
| 1096 | + } | ||
| 1097 | + | ||
| 1098 | + //切换MS ->_param->{reConnect:false} //reConnect(是否立即替换当前的ip并且重新连接) | ||
| 1099 | + _switchMsIpHandler(_param) { | ||
| 1100 | + if (GlobalConfig.isRecordPlayBack) { | ||
| 1101 | + //录制回放不做操作 | ||
| 1102 | + loger.warn('录制回放->不进行MS动态选点'); | ||
| 1103 | + return; | ||
| 1104 | + } | ||
| 1105 | + let _this = this; | ||
| 1106 | + this._getFastestMsServer(function (_data) { | ||
| 1107 | + loger.log("MS选点结束->", _data); | ||
| 1108 | + //记录当前的IP地址,选点结束后需要判断一下是否是新的IP; | ||
| 1109 | + let oldIp = GlobalConfig.MS_PUBLISH_IP; | ||
| 1110 | + | ||
| 1111 | + if (_data && _data.ip) { | ||
| 1112 | + | ||
| 1113 | + GlobalConfig.MS_PUBLISH_IP = _data.ip || ""; | ||
| 1114 | + GlobalConfig.MS_PUBLISH_PORT = _data.port || ""; | ||
| 1115 | + } else { | ||
| 1116 | + //随机选择一个 | ||
| 1117 | + if (GlobalConfig.msListFinal && GlobalConfig.msListFinal.length > 0) { | ||
| 1118 | + let index = parseInt(Math.random() * GlobalConfig.msListFinal.length); | ||
| 1119 | + GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msListFinal[index].ip || ""; | ||
| 1120 | + GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msListFinal[index].port || ""; | ||
| 1121 | + } | ||
| 1122 | + } | ||
| 1123 | + | ||
| 1124 | + if (oldIp && oldIp != GlobalConfig.MS_PUBLISH_IP) { | ||
| 1125 | + //选点完成需要更新用户数据 | ||
| 1126 | + if (_confer_ape) { | ||
| 1127 | + _confer_ape.updateUserInfo(); | ||
| 1128 | + } | ||
| 1129 | + loger.log('MS->最新地址->', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT); | ||
| 1130 | + } else { | ||
| 1131 | + //如果选点结束后获得的ip和当前的IP相同,不需要切换 | ||
| 1132 | + loger.log('MS不需要切换->IP', GlobalConfig.MS_PUBLISH_IP); | ||
| 1133 | + } | ||
| 1134 | + }); | ||
| 1135 | + } | ||
| 1136 | + | ||
| 1137 | + //切换MS -PULL地址 | ||
| 1138 | + _switchRtmpPullIpHandler(_param) { | ||
| 1139 | + if (GlobalConfig.isRecordPlayBack) { | ||
| 1140 | + //录制回放不做操作 | ||
| 1141 | + loger.warn('录制回放->不进行MS-PULL动态选点'); | ||
| 1142 | + return; | ||
| 1143 | + } | ||
| 1144 | + if(!GlobalConfig.rtmpPullListFinal||GlobalConfig.rtmpPullListFinal.length<1){ | ||
| 1145 | + return; | ||
| 1146 | + } | ||
| 1147 | + let _this = this; | ||
| 1148 | + this._getFastestRtmpPullServer(function (_data) { | ||
| 1149 | + loger.log("MS->PULL->选点结束->", _data); | ||
| 1150 | + if (_data && _data.ip) { | ||
| 1151 | + GlobalConfig.MS_PLAY_RTMP_IP = _data.ip || ""; | ||
| 1152 | + GlobalConfig.MS_PLAY_RTMP_PORT = _data.port || ""; | ||
| 1153 | + } else { | ||
| 1154 | + //随机选择一个 | ||
| 1155 | + if (GlobalConfig.rtmpPullListFinal && GlobalConfig.rtmpPullListFinal.length > 0) { | ||
| 1156 | + let index = parseInt(Math.random() * GlobalConfig.rtmpPullListFinal.length); | ||
| 1157 | + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.rtmpPullListFinal[index].ip || ""; | ||
| 1158 | + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.rtmpPullListFinal[index].port || ""; | ||
| 1159 | + } | ||
| 1160 | + } | ||
| 1161 | + //如果RTMP没有配置地址,那么还是使用推流的地址 | ||
| 1162 | + if(!GlobalConfig.MS_PLAY_RTMP_IP){ | ||
| 1163 | + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP; | ||
| 1164 | + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.MS_PUBLISH_PORT; | ||
| 1165 | + } | ||
| 1166 | + }); | ||
| 1167 | + } | ||
| 1168 | + | ||
| 1169 | + //切换MS HLS地址 | ||
| 1170 | + _switchHlsIpHandler(_param) { | ||
| 1171 | + if (GlobalConfig.isRecordPlayBack) { | ||
| 1172 | + //录制回放不做操作 | ||
| 1173 | + loger.warn('录制回放->不进行MS-HLS动态选点'); | ||
| 1174 | + return; | ||
| 1175 | + } | ||
| 1176 | + if(!GlobalConfig.hlsPullListFinal||GlobalConfig.hlsPullListFinal.length<1){ | ||
| 1177 | + return; | ||
| 1178 | + } | ||
| 1179 | + let _this = this; | ||
| 1180 | + this._getFastestHlsServer(function (_data) { | ||
| 1181 | + loger.log("HLS选点结束->", _data); | ||
| 1182 | + if (_data && _data.ip) { | ||
| 1183 | + GlobalConfig.MS_PLAY_HLS_IP = _data.ip || ""; | ||
| 1184 | + GlobalConfig.MS_PLAY_HLS_PORT = _data.port || ""; | ||
| 1185 | + } else { | ||
| 1186 | + //随机选择一个 | ||
| 1187 | + if (GlobalConfig.hlsPullListFinal && GlobalConfig.hlsPullListFinal.length > 0) { | ||
| 1188 | + let index = parseInt(Math.random() * GlobalConfig.hlsPullListFinal.length); | ||
| 1189 | + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsPullListFinal[index].ip || ""; | ||
| 1190 | + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsPullListFinal[index].port || ""; | ||
| 1191 | + } | ||
| 1192 | + } | ||
| 1193 | + //如果HLS没有配置地址,那么还是使用推流的地址 | ||
| 1194 | + if(!GlobalConfig.MS_PLAY_HLS_IP){ | ||
| 1195 | + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP; | ||
| 1196 | + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT; | ||
| 1197 | + } | ||
| 1198 | + }); | ||
| 1199 | + } | ||
| 1200 | + | ||
| 1201 | + //先通过Sass删除文档数据,删除成功之后才能删除MCU的 | ||
| 1202 | + _sassDeleteDocument(_param) { | ||
| 1203 | + if (!_mcu.connected) { | ||
| 1204 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1205 | + return; | ||
| 1206 | + } | ||
| 1207 | + | ||
| 1208 | + //判断传入的参数是否存在 | ||
| 1209 | + if (_param == null || EngineUtils.isEmptyObject(_param)) { | ||
| 1210 | + loger.error('删除文档失败->参数错误', _param); | ||
| 1211 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_DOC_DELETE_FAILED_PARAM); | ||
| 1212 | + return; | ||
| 1213 | + } | ||
| 1214 | + //判断必要的参数字段值 | ||
| 1215 | + if (_param.itemIdx == null || isNaN(_param.itemIdx) || _param.docId == null || _param.docId == "") { | ||
| 1216 | + loger.error('删除文档失败->', _param); | ||
| 1217 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_DOC_DELETE_FAILED_PARAM); | ||
| 1218 | + return; | ||
| 1219 | + } | ||
| 1220 | + loger.log('删除文档->', _param); | ||
| 1221 | + | ||
| 1222 | + if (_sass) { | ||
| 1223 | + _sass.sassDeleteDocument(_param); | ||
| 1224 | + } | ||
| 1225 | + } | ||
| 1226 | + | ||
| 1227 | + _sendDocBroadcastMsg(_param) { | ||
| 1228 | + if (!_mcu.connected) { | ||
| 1229 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1230 | + return; | ||
| 1231 | + } | ||
| 1232 | + if (_doc_ape) { | ||
| 1233 | + _doc_ape.sendDocBroadcastMsg(_param); | ||
| 1234 | + } | ||
| 1235 | + } | ||
| 1236 | + | ||
| 1237 | + //Sass删除文档成功之后,同步删除MCU数据 | ||
| 1238 | + _sassDeleteDocumentSuccess(_param) { | ||
| 1239 | + loger.log('删除文档成功->', _param); | ||
| 1240 | + this._sendDocumentDelete(_param); | ||
| 1241 | + } | ||
| 1242 | + | ||
| 1243 | + _sassDeleteMediaShareSuccess(_param) { | ||
| 1244 | + loger.log('删除媒体文件成功->', _param); | ||
| 1245 | + this._sendMediaSharedDelete(_param); | ||
| 1246 | + } | ||
| 1247 | + | ||
| 1248 | + _sassDeleteMusicShareSuccess(_param) { | ||
| 1249 | + loger.log('删除Music文件成功->', _param); | ||
| 1250 | + this._sendMusicSharedDelete(_param); | ||
| 1251 | + } | ||
| 1252 | + | ||
| 1253 | + //ConferApe | ||
| 1254 | + //开始上课 | ||
| 1255 | + _sendStartClass(_param) { | ||
| 1256 | + if (!_mcu.connected) { | ||
| 1257 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1258 | + return; | ||
| 1259 | + } | ||
| 1260 | + | ||
| 1261 | + if (_confer_ape) { | ||
| 1262 | + _confer_ape.startClass(_param); | ||
| 1263 | + } | ||
| 1264 | + } | ||
| 1265 | + | ||
| 1266 | + //ConferApe | ||
| 1267 | + //全局禁言 | ||
| 1268 | + _silenceClass(_param) { | ||
| 1269 | + if (!_mcu.connected) { | ||
| 1270 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1271 | + return; | ||
| 1272 | + } | ||
| 1273 | + | ||
| 1274 | + if (_confer_ape) { | ||
| 1275 | + _confer_ape.silenceClass(_param); | ||
| 1276 | + } | ||
| 1277 | + } | ||
| 1278 | + | ||
| 1279 | + //暂停上课 | ||
| 1280 | + _sendPauseClass(_param) { | ||
| 1281 | + if (!_mcu.connected) { | ||
| 1282 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1283 | + return; | ||
| 1284 | + } | ||
| 1285 | + if (_confer_ape) { | ||
| 1286 | + _confer_ape.pauseClass(_param); | ||
| 1287 | + } | ||
| 1288 | + } | ||
| 1289 | + | ||
| 1290 | + //更新设备信息 | ||
| 1291 | + _updateDeviceInfo(_param) { | ||
| 1292 | + if (!_mcu.connected) { | ||
| 1293 | + loger.warn('更新设备信息->失败', GlobalConfig.getCurrentStatus()); | ||
| 1294 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1295 | + } | ||
| 1296 | + if (!GlobalConfig.classJoinSuccess) { | ||
| 1297 | + loger.warn('更新设备信息->失败->还没有加入课堂成功', GlobalConfig.getCurrentStatus()); | ||
| 1298 | + } | ||
| 1299 | + if (_confer_ape) { | ||
| 1300 | + _confer_ape.updateDeviceInfo(_param); | ||
| 1301 | + } | ||
| 1302 | + } | ||
| 1303 | + | ||
| 1304 | + //文档-媒体共享-屏幕共享模块切换 | ||
| 1305 | + _sceneTableChange(_param) { | ||
| 1306 | + if (!_mcu.connected) { | ||
| 1307 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1308 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1309 | + } | ||
| 1310 | + if (_confer_ape) { | ||
| 1311 | + _confer_ape.sceneTableChange(_param); | ||
| 1312 | + } | ||
| 1313 | + } | ||
| 1314 | + | ||
| 1315 | + //通过第三方消息通道发送消息 | ||
| 1316 | + _sendThridChannelMessage(_param) { | ||
| 1317 | + if (!_mcu.connected) { | ||
| 1318 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1319 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1320 | + } | ||
| 1321 | + if (_confer_ape) { | ||
| 1322 | + _confer_ape.onThirdReciveParentMessage(_param); | ||
| 1323 | + } | ||
| 1324 | + } | ||
| 1325 | + | ||
| 1326 | + //将指定nodeId的人踢出课堂 | ||
| 1327 | + _kickOutRosterFormNodeId(_param) { | ||
| 1328 | + if (!_mcu.connected) { | ||
| 1329 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1330 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1331 | + } | ||
| 1332 | + if (_confer_ape) { | ||
| 1333 | + _confer_ape.kickOutRosterFormNodeId(_param); | ||
| 1334 | + } | ||
| 1335 | + } | ||
| 1336 | + | ||
| 1337 | + // 禁言控制 | ||
| 1338 | + _controlSilenceStatus(_param) { | ||
| 1339 | + if (!_mcu.connected) { | ||
| 1340 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1341 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1342 | + } | ||
| 1343 | + if (_confer_ape) { | ||
| 1344 | + _confer_ape.controlSilenceStatus(_param); | ||
| 1345 | + } | ||
| 1346 | + } | ||
| 1347 | + | ||
| 1348 | + //举手状态控制 | ||
| 1349 | + _controlHandUpStatus(_param) { | ||
| 1350 | + if (!_mcu.connected) { | ||
| 1351 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1352 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1353 | + } | ||
| 1354 | + if (_confer_ape) { | ||
| 1355 | + _confer_ape.controlHandUpStatus(_param); | ||
| 1356 | + } | ||
| 1357 | + } | ||
| 1358 | + | ||
| 1359 | + //举手状态切换 | ||
| 1360 | + _changeHandUpStatus(_param) { | ||
| 1361 | + if (!_mcu.connected) { | ||
| 1362 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1363 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1364 | + } | ||
| 1365 | + if (_confer_ape) { | ||
| 1366 | + _confer_ape.changeHandUpStatus(_param); | ||
| 1367 | + } | ||
| 1368 | + } | ||
| 1369 | + | ||
| 1370 | + //停止上课 | ||
| 1371 | + _sendCloseClass(_param) { | ||
| 1372 | + if (!_mcu.connected) { | ||
| 1373 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1374 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1375 | + } | ||
| 1376 | + if (_confer_ape) { | ||
| 1377 | + _confer_ape.closeClass(_param); | ||
| 1378 | + } | ||
| 1379 | + } | ||
| 1380 | + | ||
| 1381 | + // 离开课堂 {type:1} type=1被踢出课堂;type=0自己主动离开 | ||
| 1382 | + _leaveClass(_param) { | ||
| 1383 | + if (!_mcu.connected) { | ||
| 1384 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1385 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1386 | + } | ||
| 1387 | + | ||
| 1388 | + //停止推流 | ||
| 1389 | + if (_video_ape) { | ||
| 1390 | + _video_ape.stopPublishVideo(); | ||
| 1391 | + _video_ape.stopPublishScreenShare(); | ||
| 1392 | + } | ||
| 1393 | + if (_audio_ape) { | ||
| 1394 | + _audio_ape.stopPublishAudio(); | ||
| 1395 | + } | ||
| 1396 | + //离开课堂 | ||
| 1397 | + if (_confer_ape) { | ||
| 1398 | + _confer_ape.stopRecord(); | ||
| 1399 | + _confer_ape.leaveClass(); | ||
| 1400 | + } | ||
| 1401 | + | ||
| 1402 | + let callBack = {}; | ||
| 1403 | + if (_param && _param.type) { | ||
| 1404 | + callBack = _param; | ||
| 1405 | + } else { | ||
| 1406 | + callBack.type = 0; | ||
| 1407 | + } | ||
| 1408 | + loger.warn('离开课堂->', MessageTypes.CLASS_EXIT, callBack); | ||
| 1409 | + this._emit(MessageTypes.CLASS_EXIT, callBack); | ||
| 1410 | + | ||
| 1411 | + //断开MCU连接 | ||
| 1412 | + if (_mcu) { | ||
| 1413 | + _mcu.leaveMCU(); | ||
| 1414 | + GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_3); | ||
| 1415 | + } | ||
| 1416 | + } | ||
| 1417 | + | ||
| 1418 | + //获取课堂所有参数(20170727新规则) api/meeting/detail.do? flash中的接口文件是 getClassParam.do | ||
| 1419 | + _sassGetClassParamSuccessHandler(_data) { | ||
| 1420 | + loger.log('获取课堂课堂信息完成.'); | ||
| 1421 | + //包含整个课堂最全的信息,储存数据 | ||
| 1422 | + if (_data) { | ||
| 1423 | + GlobalConfig.mcuDelay = _data.h5Delay || 0; //mcu消息延迟的时间间隔,单位(秒),结合客户端传的messageDelay的值使用 | ||
| 1424 | + GlobalConfig.className = _data.meetingName || ""; | ||
| 1425 | + GlobalConfig.classBeginTime = _data.beginTime || ""; | ||
| 1426 | + GlobalConfig.classEndTime = _data.endTime || ""; | ||
| 1427 | + GlobalConfig.userIp = _data.userIp || ""; | ||
| 1428 | + | ||
| 1429 | + GlobalConfig.maxVideoChannels = _data.maxVideoChannels; | ||
| 1430 | + GlobalConfig.maxAudioChannels = _data.maxAudioChannels; | ||
| 1431 | + GlobalConfig.maxMediaChannels = Math.max(GlobalConfig.maxVideoChannels, GlobalConfig.maxAudioChannels); | ||
| 1432 | + | ||
| 1433 | + GlobalConfig.ssTunnelAppURL = _data.ssTunnelAppURL || ''; //屏幕共享插件的地址 | ||
| 1434 | + | ||
| 1435 | + //视频质量相关设置,每次加入课堂都按最新的获取设置 | ||
| 1436 | + GlobalConfig.fps = _data.fps || 15; | ||
| 1437 | + GlobalConfig.gop = _data.gop || 3; | ||
| 1438 | + GlobalConfig.videoQuality = parseInt(_data.videoQuality); | ||
| 1439 | + GlobalConfig.curVideoQuality = GlobalConfig.videoQuality; | ||
| 1440 | + | ||
| 1441 | + //是否自动开始(身份是host的时候才用到的) | ||
| 1442 | + GlobalConfig.isAutoStartClass = _data.autoRecord || 0; | ||
| 1443 | + | ||
| 1444 | + GlobalConfig.serverTime = _data.serverTime || new Date().getTime(); //获取服务器时间戳 | ||
| 1445 | + GlobalConfig.serverAndLoacTimeDistanc = (new Date().getTime() - GlobalConfig.serverTime) / 1000; //当前系统时间和服务器时间的差值 (秒) | ||
| 1446 | + loger.warn("服务器时间:" + GlobalConfig.serverTime + " 系统时间:" + new Date().getTime() + " 时间差:" + GlobalConfig.serverAndLoacTimeDistanc); | ||
| 1447 | + | ||
| 1448 | + | ||
| 1449 | + GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表 | ||
| 1450 | + GlobalConfig.setRecordList(_data.recordList); //录制回放地址 | ||
| 1451 | + GlobalConfig.setDocList(_data.docList); //文档地址 | ||
| 1452 | + GlobalConfig.setMusicList(_data.musicList); // | ||
| 1453 | + GlobalConfig.setMusicListPrepare(_data.musicListPrepare); //提前上传的声音文件列表 | ||
| 1454 | + GlobalConfig.setVideoCDNAddr(_data.videoCDNAddr); //cdn加速的拉流地址,直播的时候才使用 | ||
| 1455 | + GlobalConfig.setMediaShareList(_data.sharedMediaList); //提前上传的媒体共享文件列表 | ||
| 1456 | + | ||
| 1457 | + //存从Sass获取的MS和MCU服务列表 | ||
| 1458 | + if (_data.msList2) { | ||
| 1459 | + GlobalConfig.setMsList(_data.msList2.msList); //储存Sass ms拉流地址 | ||
| 1460 | + GlobalConfig.setRtmpPullList(_data.msList2.rtmpPullArray); //储存Sass ms拉流地址 | ||
| 1461 | + GlobalConfig.setHlsPullList(_data.msList2.hlsPullArray); //储存Sass ms拉流地址 | ||
| 1462 | + GlobalConfig.setRsList(_data.msList2.rsList); //储存Sass 录制回放hls拉流地址 | ||
| 1463 | + } | ||
| 1464 | + //Sass mcu | ||
| 1465 | + GlobalConfig.setMcuList(_data.mcuList); //mcu | ||
| 1466 | + | ||
| 1467 | + loger.warn('从Sass获取的推流拉流列表数据:'); | ||
| 1468 | + loger.warn('Sass->msList->', GlobalConfig.msList); | ||
| 1469 | + loger.warn('Sass->rtmpPullList->', GlobalConfig.rtmpPullList); | ||
| 1470 | + loger.warn('Sass->hlsPullList->', GlobalConfig.hlsPullList); | ||
| 1471 | + loger.warn('Sass->rsList->', GlobalConfig.rsList); | ||
| 1472 | + | ||
| 1473 | + //没有加载server.json之前,最终的服务列表按Sass的为准,server.json加载完成后会选点 | ||
| 1474 | + GlobalConfig.msListFinal=GlobalConfig.msList; | ||
| 1475 | + GlobalConfig.rtmpPullListFinal=GlobalConfig.rtmpPullList; | ||
| 1476 | + GlobalConfig.hlsPullListFinal=GlobalConfig.hlsPullList; | ||
| 1477 | + GlobalConfig.rsPullListFinal=GlobalConfig.rsList; | ||
| 1478 | + GlobalConfig.mcuListFinal=GlobalConfig.mcuList; | ||
| 1479 | + } | ||
| 1480 | + | ||
| 1481 | + //课堂获取Sass数据完成 | ||
| 1482 | + this._emit(MessageTypes.CLASS_GET_INFO_SUCCESS, GlobalConfig.getClassInfo()); | ||
| 1483 | + | ||
| 1484 | + if (_data.currentInfo) { | ||
| 1485 | + //根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息 | ||
| 1486 | + try { | ||
| 1487 | + GlobalConfig.setClassStatusInfo(JSON.parse(_data.currentInfo)); | ||
| 1488 | + } catch (err) { | ||
| 1489 | + loger.warn("从Sass获取的课堂数据JSON转换失败->"); | ||
| 1490 | + console.log("currentInfo", _data.currentInfo); | ||
| 1491 | + GlobalConfig.setClassStatusInfo(_data.currentInfo); | ||
| 1492 | + } | ||
| 1493 | + loger.log(GlobalConfig.classStatusInfo); | ||
| 1494 | + } else { | ||
| 1495 | + loger.log("还没有保存过课堂状信息"); | ||
| 1496 | + } | ||
| 1497 | + | ||
| 1498 | + //课堂数据获取完成->进入课堂或进入录制回放 | ||
| 1499 | + //录制回放不需要获取ip信息和选点 | ||
| 1500 | + if (GlobalConfig.isRecordPlayBack) { | ||
| 1501 | + if (_recordPlayback) { | ||
| 1502 | + //获取MCU和MS 推流拉流、录制回放的默认地址 | ||
| 1503 | + this.getMcuAndMsDefaultServerIp(); | ||
| 1504 | + //开启录制回放流程 | ||
| 1505 | + loger.warn("开启录制回放流程"); | ||
| 1506 | + _recordPlayback.readyRecordPlay(); | ||
| 1507 | + } else { | ||
| 1508 | + loger.warn("开启录制回放流程失败->还未创建模块"); | ||
| 1509 | + } | ||
| 1510 | + } else { | ||
| 1511 | + //根据用户的userIp获取信息,获取服务列表选点,选点测速完成后才加入MCU | ||
| 1512 | + this.loadServerJsonAndgetUserIpInfo(); | ||
| 1513 | + } | ||
| 1514 | + } | ||
| 1515 | + | ||
| 1516 | + //获取各个服务的默认ip,之后会进行测速选择更快的ip | ||
| 1517 | + getMcuAndMsDefaultServerIp() { | ||
| 1518 | + //MCU地址 | ||
| 1519 | + if (GlobalConfig.mcuListFinal && GlobalConfig.mcuListFinal.length > 0) { | ||
| 1520 | + //还未开始选点之前随机选择一个 | ||
| 1521 | + let index = parseInt(Math.random() * GlobalConfig.mcuListFinal.length); | ||
| 1522 | + GlobalConfig.MCUServerIP = GlobalConfig.mcuListFinal[index].ip || ""; | ||
| 1523 | + GlobalConfig.MCUServerPort = GlobalConfig.mcuListFinal[index].port || ""; | ||
| 1524 | + } | ||
| 1525 | + | ||
| 1526 | + //录制回放时m3u8播流地址 | ||
| 1527 | + if (GlobalConfig.rsPullListFinal && GlobalConfig.rsPullListFinal.length > 0) { | ||
| 1528 | + //还未开始选点之前随机选择一个 | ||
| 1529 | + let index = parseInt(Math.random() * GlobalConfig.rsPullListFinal.length); | ||
| 1530 | + GlobalConfig.RS_RECORD_PLAY_IP = GlobalConfig.rsPullListFinal[index].ip || ""; | ||
| 1531 | + GlobalConfig.RS_RECORD_PLAY_PORT = GlobalConfig.rsPullListFinal[index].port || ""; | ||
| 1532 | + } | ||
| 1533 | + | ||
| 1534 | + //推流地址 | ||
| 1535 | + if (GlobalConfig.msListFinal && GlobalConfig.msListFinal.length > 0) { | ||
| 1536 | + //还未开始选点之前随机选择一个 | ||
| 1537 | + let index = parseInt(Math.random() * GlobalConfig.msListFinal.length); | ||
| 1538 | + GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msListFinal[index].ip || ""; | ||
| 1539 | + GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msListFinal[index].port || ""; | ||
| 1540 | + } | ||
| 1541 | + | ||
| 1542 | + //RTMP拉流 | ||
| 1543 | + if (GlobalConfig.rtmpPullListFinal && GlobalConfig.rtmpPullListFinal.length > 0) { | ||
| 1544 | + // //还未开始选点之前随机选择一个 | ||
| 1545 | + let index = parseInt(Math.random() * GlobalConfig.rtmpPullListFinal.length); | ||
| 1546 | + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.rtmpPullListFinal[index].ip || ""; | ||
| 1547 | + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.rtmpPullListFinal[index].port || ""; | ||
| 1548 | + } else { | ||
| 1549 | + //如果没有单独的rtmp拉流地址,和推流地址一样即可 | ||
| 1550 | + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP; | ||
| 1551 | + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.MS_PUBLISH_PORT; | ||
| 1552 | + } | ||
| 1553 | + | ||
| 1554 | + //课堂中HLS拉流地址 | ||
| 1555 | + if (GlobalConfig.hlsPullListFinal && GlobalConfig.hlsPullListFinal.length > 0) { | ||
| 1556 | + //有单独的hls拉流地址 | ||
| 1557 | + let index = parseInt(Math.random() * GlobalConfig.hlsPullListFinal.length); | ||
| 1558 | + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsPullListFinal[index].ip || ""; | ||
| 1559 | + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsPullListFinal[index].port || ""; | ||
| 1560 | + } else { | ||
| 1561 | + //没有单独的hls拉流地址,和录制回放地址一样即可 | ||
| 1562 | + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP; | ||
| 1563 | + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT; | ||
| 1564 | + } | ||
| 1565 | + | ||
| 1566 | + | ||
| 1567 | + //文档服务器地址 | ||
| 1568 | + if (GlobalConfig.docList && GlobalConfig.docList.length > 0) { | ||
| 1569 | + //doc上传地址,随机获取一个 | ||
| 1570 | + let index = parseInt(Math.random() * GlobalConfig.docList.length); | ||
| 1571 | + GlobalConfig.DOCServerIP = GlobalConfig.docList[index].ip || ""; | ||
| 1572 | + GlobalConfig.DOCServerPort = GlobalConfig.docList[index].port || ""; | ||
| 1573 | + | ||
| 1574 | + } | ||
| 1575 | + //录制回放文件的下载地址 | ||
| 1576 | + if (GlobalConfig.recordList && GlobalConfig.recordList.length > 0) { | ||
| 1577 | + let index = parseInt(Math.random() * GlobalConfig.recordList.length); | ||
| 1578 | + GlobalConfig.RecordServerIP = GlobalConfig.recordList[index].ip || ""; | ||
| 1579 | + GlobalConfig.RecordServerPort = GlobalConfig.recordList[index].port || ""; | ||
| 1580 | + | ||
| 1581 | + } | ||
| 1582 | + loger.warn('默认->MCU地址->.', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); | ||
| 1583 | + | ||
| 1584 | + loger.warn('默认->MS推流地址->.', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT); | ||
| 1585 | + loger.warn('默认->HLS点播地址->.', GlobalConfig.RS_RECORD_PLAY_IP, GlobalConfig.RS_RECORD_PLAY_PORT); | ||
| 1586 | + loger.warn('默认->HLS拉流地址->.', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT); | ||
| 1587 | + loger.warn('默认->RTMP拉流地址->.', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT); | ||
| 1588 | + | ||
| 1589 | + loger.warn('默认->文档服务器地址->.', GlobalConfig.DOCServerIP, GlobalConfig.DOCServerPort); | ||
| 1590 | + loger.warn('默认->录制回放文件下载地址->.', GlobalConfig.RecordServerIP, GlobalConfig.RecordServerPort); | ||
| 1591 | + } | ||
| 1592 | + | ||
| 1593 | + //获取课堂所有参数 api/meeting/detail.do? flash中的接口文件是 getClassParam.do(20170727之前的规则) | ||
| 1594 | + /*_sassGetClassParamSuccessHandler(_data) { | ||
| 1595 | + loger.log('获取课堂课堂信息完成.'); | ||
| 1596 | + //包含整个课堂最全的信息,储存数据 | ||
| 1597 | + if (_data) { | ||
| 1598 | + GlobalConfig.mcuDelay = _data.h5Delay || 0; //mcu消息延迟的时间间隔,单位(秒),结合客户端传的messageDelay的值使用 | ||
| 1599 | + GlobalConfig.className = _data.meetingName || ""; | ||
| 1600 | + GlobalConfig.classBeginTime = _data.beginTime || ""; | ||
| 1601 | + GlobalConfig.classEndTime = _data.endTime || ""; | ||
| 1602 | + GlobalConfig.userIp = _data.userIp || ""; | ||
| 1603 | + | ||
| 1604 | + GlobalConfig.maxVideoChannels = _data.maxVideoChannels; | ||
| 1605 | + GlobalConfig.maxAudioChannels = _data.maxAudioChannels; | ||
| 1606 | + GlobalConfig.maxMediaChannels = Math.max(GlobalConfig.maxVideoChannels, GlobalConfig.maxAudioChannels); | ||
| 1607 | + | ||
| 1608 | + GlobalConfig.ssTunnelAppURL = _data.ssTunnelAppURL || ''; //屏幕共享插件的地址 | ||
| 1609 | + | ||
| 1610 | + //视频质量相关设置,每次加入课堂都按最新的获取设置 | ||
| 1611 | + GlobalConfig.fps = _data.fps || 15; | ||
| 1612 | + GlobalConfig.gop = _data.gop || 3; | ||
| 1613 | + GlobalConfig.videoQuality = parseInt(_data.videoQuality); | ||
| 1614 | + GlobalConfig.curVideoQuality = GlobalConfig.videoQuality; | ||
| 1615 | + | ||
| 1616 | + //是否自动开始(身份是host的时候才用到的) | ||
| 1617 | + GlobalConfig.isAutoStartClass = _data.autoRecord || 0; | ||
| 1618 | + | ||
| 1619 | + GlobalConfig.serverTime = _data.serverTime || new Date().getTime(); //获取服务器时间戳 | ||
| 1620 | + GlobalConfig.serverAndLoacTimeDistanc = (new Date().getTime() - GlobalConfig.serverTime) / 1000; //当前系统时间和服务器时间的差值 (秒) | ||
| 1621 | + loger.warn("服务器时间:" + GlobalConfig.serverTime + " 系统时间:" + new Date().getTime() + " 时间差:" + GlobalConfig.serverAndLoacTimeDistanc); | ||
| 1622 | + | ||
| 1623 | + GlobalConfig.setDocListPrepare(_data.docListPrepare); //提前上传的文档列表 | ||
| 1624 | + GlobalConfig.setRecordList(_data.recordList); //录制回放地址 | ||
| 1625 | + GlobalConfig.setDocList(_data.docList); //文档地址 | ||
| 1626 | + GlobalConfig.setMsList(_data.msList); //推流播流服务器地址(需要对列表中的地址进行分类,里面包含了推流和拉流的地址,目前主要是乐视的需要区分开) | ||
| 1627 | + GlobalConfig.setRsList(_data.rsList); //播放m3u8格式的地址(录制回放时使用) | ||
| 1628 | + GlobalConfig.setMcuList(_data.mcuList); //mcu | ||
| 1629 | + GlobalConfig.setMusicList(_data.musicList); // | ||
| 1630 | + GlobalConfig.setMusicListPrepare(_data.musicListPrepare); //提前上传的声音文件列表 | ||
| 1631 | + GlobalConfig.setVideoCDNAddr(_data.videoCDNAddr); //cdn加速的拉流地址,直播的时候才使用 | ||
| 1632 | + GlobalConfig.setMediaShareList(_data.sharedMediaList); //提前上传的媒体共享文件列表 | ||
| 1633 | + | ||
| 1634 | + //MCU地址 | ||
| 1635 | + if (_data.mcuList && _data.mcuList.length > 0) { | ||
| 1636 | + //随机选择一个 | ||
| 1637 | + let index = parseInt(Math.random() * _data.mcuList.length); | ||
| 1638 | + GlobalConfig.MCUServerIP = _data.mcuList[index].ip || ""; | ||
| 1639 | + GlobalConfig.MCUServerPort = _data.mcuList[index].port || ""; | ||
| 1640 | + loger.log('初始->MCU->.', GlobalConfig.MCUServerIP, GlobalConfig.MCUServerPort); | ||
| 1641 | + } | ||
| 1642 | + | ||
| 1643 | + //录制回放时m3u8播流地址 | ||
| 1644 | + if (_data.rsList && _data.rsList.length > 0) { | ||
| 1645 | + let index = parseInt(Math.random() * _data.rsList.length); | ||
| 1646 | + GlobalConfig.RS_RECORD_PLAY_IP = _data.rsList[index].ip || ""; | ||
| 1647 | + GlobalConfig.RS_RECORD_PLAY_PORT = _data.rsList[index].port || ""; | ||
| 1648 | + loger.log('初始->RS->.', GlobalConfig.RS_RECORD_PLAY_IP, GlobalConfig.RS_RECORD_PLAY_PORT); | ||
| 1649 | + } | ||
| 1650 | + | ||
| 1651 | + //上课中音视频推流地址 | ||
| 1652 | + if (GlobalConfig.msList && GlobalConfig.msList.length > 0) { | ||
| 1653 | + let index = parseInt(Math.random() * GlobalConfig.msList.length); | ||
| 1654 | + GlobalConfig.MS_PUBLISH_IP = GlobalConfig.msList[index].ip || ""; | ||
| 1655 | + GlobalConfig.MS_PUBLISH_PORT = GlobalConfig.msList[index].port || ""; | ||
| 1656 | + } | ||
| 1657 | + loger.log('初始->MS->.', GlobalConfig.MS_PUBLISH_IP, GlobalConfig.MS_PUBLISH_PORT); | ||
| 1658 | + | ||
| 1659 | + //播流的地址和推流地址需要分开的时候,单独设置拉流的地址 rtmp(目前乐视使用) | ||
| 1660 | + if (GlobalConfig.rtmpPullList && GlobalConfig.rtmpPullList.length > 0) { | ||
| 1661 | + //有单独的rtmp拉流地址 | ||
| 1662 | + let index = parseInt(Math.random() * GlobalConfig.rtmpPullList.length); | ||
| 1663 | + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.rtmpPullList[index].ip || ""; | ||
| 1664 | + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.rtmpPullList[index].port || ""; | ||
| 1665 | + } else { | ||
| 1666 | + //如果没有单独的rtmp拉流地址,和推流地址一样即可 | ||
| 1667 | + GlobalConfig.MS_PLAY_RTMP_IP = GlobalConfig.MS_PUBLISH_IP; | ||
| 1668 | + GlobalConfig.MS_PLAY_RTMP_PORT = GlobalConfig.MS_PUBLISH_PORT; | ||
| 1669 | + } | ||
| 1670 | + | ||
| 1671 | + loger.log('初始->MSPull->.', GlobalConfig.MS_PLAY_RTMP_IP, GlobalConfig.MS_PLAY_RTMP_PORT); | ||
| 1672 | + | ||
| 1673 | + //播流的地址和推流地址需要分开的时候,单独设置拉流的地址 hls(目前乐视使用) | ||
| 1674 | + if (GlobalConfig.hlsList && GlobalConfig.hlsList.length > 0) { | ||
| 1675 | + //有单独的hls拉流地址 | ||
| 1676 | + let index = parseInt(Math.random() * GlobalConfig.hlsList.length); | ||
| 1677 | + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.hlsList[index].ip || ""; | ||
| 1678 | + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.hlsList[index].port || ""; | ||
| 1679 | + } else { | ||
| 1680 | + //没有单独的hls拉流地址,和录制回放地址一样即可 | ||
| 1681 | + GlobalConfig.MS_PLAY_HLS_IP = GlobalConfig.RS_RECORD_PLAY_IP; | ||
| 1682 | + GlobalConfig.MS_PLAY_HLS_PORT = GlobalConfig.RS_RECORD_PLAY_PORT; | ||
| 1683 | + } | ||
| 1684 | + loger.log('初始->MSHls->.', GlobalConfig.MS_PLAY_HLS_IP, GlobalConfig.MS_PLAY_HLS_PORT); | ||
| 1685 | + | ||
| 1686 | + //直播的时候,拉流(rtmp和hls)需要从 videoCDNAddr中获取 | ||
| 1687 | + //20170531-新规则,所有课堂类型都支持加速 | ||
| 1688 | + // if(GlobalConfig.classType==ApeConsts.CLASS_TYPE_2&&GlobalConfig.videoCDNAddrList.length>0){ | ||
| 1689 | + | ||
| 1690 | + //20170629-直播课堂和移动端设备的时候支持 | ||
| 1691 | + if (GlobalConfig.classType == ApeConsts.CLASS_TYPE_2 || GlobalConfig.isMobile) { | ||
| 1692 | + if (GlobalConfig.videoCDNAddrList.length > 0) { | ||
| 1693 | + //videoCDNAddrList中rtmppush和hls是混在一起的,需要分离开; | ||
| 1694 | + let listLen = GlobalConfig.videoCDNAddrList.length; | ||
| 1695 | + for (let i = 0; i < listLen; i++) { | ||
| 1696 | + let ipItem = GlobalConfig.videoCDNAddrList[i]; | ||
| 1697 | + if (ipItem) { | ||
| 1698 | + if (ipItem.indexOf('hls') >= 0) { | ||
| 1699 | + //直播的时候m3u8拉流地址 | ||
| 1700 | + GlobalConfig.MS_PLAY_HLS_IP = ipItem; //ip包含了端口 | ||
| 1701 | + GlobalConfig.MS_PLAY_HLS_PORT = ""; | ||
| 1702 | + loger.log('videoCDNAddr>初始->MSHls', GlobalConfig.MS_PLAY_HLS_IP); | ||
| 1703 | + } | ||
| 1704 | + if (ipItem.indexOf('rtmppull')>= 0) { | ||
| 1705 | + //直播的时候rtmp拉流地址 | ||
| 1706 | + GlobalConfig.MS_PLAY_RTMP_IP = ipItem; //ip包含了端口 | ||
| 1707 | + GlobalConfig.MS_PLAY_RTMP_PORT = ''; | ||
| 1708 | + loger.log('videoCDNAddr->初始->MSPull', GlobalConfig.MS_PLAY_RTMP_IP); | ||
| 1709 | + } | ||
| 1710 | + } | ||
| 1711 | + } | ||
| 1712 | + } else { | ||
| 1713 | + loger.error('videoCDNAddr数据无效->', GlobalConfig.videoCDNAddr); | ||
| 1714 | + } | ||
| 1715 | + } else { | ||
| 1716 | + loger.warn('非直播课堂或不是移动端->不需要videoCDN加速'); | ||
| 1717 | + } | ||
| 1718 | + | ||
| 1719 | + //文档地址 | ||
| 1720 | + if (_data.docList && _data.docList.length > 0) { | ||
| 1721 | + //doc上传地址,随机获取一个 | ||
| 1722 | + let index = parseInt(Math.random() * _data.docList.length); | ||
| 1723 | + loger.log("docServer->", _data.docList[index]); | ||
| 1724 | + GlobalConfig.DOCServerIP = _data.docList[index].ip || ""; | ||
| 1725 | + GlobalConfig.DOCServerPort = _data.docList[index].port || ""; | ||
| 1726 | + loger.log('初始->DOC->.', GlobalConfig.DOCServerIP, GlobalConfig.DOCServerPort); | ||
| 1727 | + } | ||
| 1728 | + | ||
| 1729 | + //record | ||
| 1730 | + if (_data.recordList && _data.recordList.length > 0) { | ||
| 1731 | + let index = parseInt(Math.random() * _data.recordList.length); | ||
| 1732 | + GlobalConfig.RecordServerIP = _data.recordList[index].ip || ""; | ||
| 1733 | + GlobalConfig.RecordServerPort = _data.recordList[index].port || ""; | ||
| 1734 | + loger.log('初始->RECORD->.', GlobalConfig.RecordServerIP, GlobalConfig.RecordServerPort); | ||
| 1735 | + } | ||
| 1736 | + | ||
| 1737 | + } | ||
| 1738 | + //这里需要考虑是否加延迟处理,课堂信息刚获取完成,客户端需要根据数据创建界面UI,等创建完成后再加入课堂是最合适的(目前没有加延迟) | ||
| 1739 | + this._emit(MessageTypes.CLASS_GET_INFO_SUCCESS, GlobalConfig.getClassInfo()); | ||
| 1740 | + | ||
| 1741 | + if (_data.currentInfo) { | ||
| 1742 | + //根据从Sass获取的数据信息,同步最后一次保存的课堂状态信息 | ||
| 1743 | + loger.log("本地同步最后一次保存过的课堂状态信息"); | ||
| 1744 | + try { | ||
| 1745 | + GlobalConfig.setClassStatusInfo(JSON.parse(_data.currentInfo)); | ||
| 1746 | + } catch (err) { | ||
| 1747 | + loger.warn("从Sass获取的课堂数据JSON转换失败->"); | ||
| 1748 | + console.log("currentInfo", _data.currentInfo); | ||
| 1749 | + GlobalConfig.setClassStatusInfo(_data.currentInfo); | ||
| 1750 | + } | ||
| 1751 | + loger.log(GlobalConfig.classStatusInfo); | ||
| 1752 | + } else { | ||
| 1753 | + loger.log("还没有保存过课堂状信息"); | ||
| 1754 | + } | ||
| 1755 | + | ||
| 1756 | + //录制回放不需要获取ip信息和选点 | ||
| 1757 | + if (GlobalConfig.isRecordPlayBack) { | ||
| 1758 | + if (_recordPlayback) { | ||
| 1759 | + //开启录制回放流程 | ||
| 1760 | + loger.log("开启录制回放流程"); | ||
| 1761 | + _recordPlayback.readyRecordPlay(); | ||
| 1762 | + } else { | ||
| 1763 | + loger.warn("开启录制回放流程失败->还未创建模块"); | ||
| 1764 | + } | ||
| 1765 | + } else { | ||
| 1766 | + //根据用户的userIp获取信息,选点 | ||
| 1767 | + this.getUserIpInfo(); | ||
| 1768 | + } | ||
| 1769 | + }*/ | ||
| 1770 | + | ||
| 1771 | + //ChatApe | ||
| 1772 | + // 发送聊天消息 | ||
| 1773 | + _sendChatMsg(_messageInfo) { | ||
| 1774 | + if (!_mcu.connected) { | ||
| 1775 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1776 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1777 | + } | ||
| 1778 | + if (_messageInfo === null || EngineUtils.isEmptyObject(_messageInfo)) { | ||
| 1779 | + loger.log('发送聊天消息失败->参数错误', _messageInfo); | ||
| 1780 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1781 | + } | ||
| 1782 | + if (_chat_ape) { | ||
| 1783 | + _chat_ape.sendChatMsg(_messageInfo); | ||
| 1784 | + } | ||
| 1785 | + } | ||
| 1786 | + | ||
| 1787 | + //监听摄像头麦克风状态 | ||
| 1788 | + userDeviecStatusChange(_data) { | ||
| 1789 | + /* nodeId:GlobalConfig.nodeId, | ||
| 1790 | + userRole:GlobalConfig.userRole, | ||
| 1791 | + userName:GlobalConfig.userName, | ||
| 1792 | + userId:GlobalConfig.userId, | ||
| 1793 | + openCamera:GlobalConfig.openCamera, | ||
| 1794 | + openMicrophones:GlobalConfig.openMicrophones*/ | ||
| 1795 | + if (_confer_ape) { | ||
| 1796 | + _confer_ape.updaterUserDeviecStatusChange(_data); | ||
| 1797 | + } | ||
| 1798 | + } | ||
| 1799 | + | ||
| 1800 | + //屏幕共享 | ||
| 1801 | + //开始屏幕共享 | ||
| 1802 | + _publishScreenShare(_param) { | ||
| 1803 | + if (_video_ape) { | ||
| 1804 | + _video_ape.publishScreenShare(_param); | ||
| 1805 | + } | ||
| 1806 | + } | ||
| 1807 | + | ||
| 1808 | + //停止屏幕共享 | ||
| 1809 | + _stopPublishScreenShare(_param) { | ||
| 1810 | + if (_video_ape) { | ||
| 1811 | + _video_ape.stopPublishScreenShare(_param); | ||
| 1812 | + } | ||
| 1813 | + } | ||
| 1814 | + | ||
| 1815 | + //VidoeApe | ||
| 1816 | + videoUpdate(_data) { | ||
| 1817 | + //视频同步的消息发送改变,需要通知ferApe模块中的用户更新状态 | ||
| 1818 | + if (_confer_ape) { | ||
| 1819 | + _confer_ape.updaterRosterStatus(_data); | ||
| 1820 | + } | ||
| 1821 | + } | ||
| 1822 | + | ||
| 1823 | + _sendVideoBroadcastMsg(_param) { | ||
| 1824 | + if (!_mcu.connected) { | ||
| 1825 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1826 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1827 | + } | ||
| 1828 | + if (_video_ape) { | ||
| 1829 | + return _video_ape.sendVideoBroadcastMsg(_param); | ||
| 1830 | + } | ||
| 1831 | + } | ||
| 1832 | + | ||
| 1833 | + _getVideoPlayPath(_param) { | ||
| 1834 | + if (_video_ape) { | ||
| 1835 | + return _video_ape.getPlayVideoPath(_param); | ||
| 1836 | + } | ||
| 1837 | + } | ||
| 1838 | + | ||
| 1839 | + _getVideoPublishPath(_param) { | ||
| 1840 | + if (_video_ape) { | ||
| 1841 | + return _video_ape.getPublishVideoPath(_param); | ||
| 1842 | + } | ||
| 1843 | + } | ||
| 1844 | + | ||
| 1845 | + _getVideoAllChannelInfo(_param) { | ||
| 1846 | + if (_video_ape) { | ||
| 1847 | + return _video_ape.getAllChannelInfo(_param); | ||
| 1848 | + } | ||
| 1849 | + } | ||
| 1850 | + | ||
| 1851 | + _publishVideo(_param) { | ||
| 1852 | + if (!_mcu.connected) { | ||
| 1853 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1854 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1855 | + } | ||
| 1856 | + if (_video_ape) { | ||
| 1857 | + return _video_ape.publishVideo(_param); | ||
| 1858 | + } | ||
| 1859 | + } | ||
| 1860 | + | ||
| 1861 | + _stopPublishVideo(_param) { | ||
| 1862 | + if (!_mcu.connected) { | ||
| 1863 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1864 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1865 | + } | ||
| 1866 | + if (_video_ape) { | ||
| 1867 | + return _video_ape.stopPublishVideo(_param); | ||
| 1868 | + } | ||
| 1869 | + } | ||
| 1870 | + | ||
| 1871 | + //AudioApe | ||
| 1872 | + audioUpdate(_data) { | ||
| 1873 | + //音频同步的消息发送改变,需要通知ferApe模块中的用户更新状态 | ||
| 1874 | + if (_confer_ape) { | ||
| 1875 | + _confer_ape.updaterRosterStatus(_data); | ||
| 1876 | + } | ||
| 1877 | + } | ||
| 1878 | + | ||
| 1879 | + sendAudioCommandMsg(_param) { | ||
| 1880 | + if (!_mcu.connected) { | ||
| 1881 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1882 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1883 | + } | ||
| 1884 | + if (_audio_ape) { | ||
| 1885 | + return _audio_ape.sendAudioBroadcastMsg(_param); | ||
| 1886 | + } | ||
| 1887 | + } | ||
| 1888 | + | ||
| 1889 | + _getPlayAudioPath(_param) { | ||
| 1890 | + if (_audio_ape) { | ||
| 1891 | + return _audio_ape.getAudioPlayPath(_param); | ||
| 1892 | + } | ||
| 1893 | + } | ||
| 1894 | + | ||
| 1895 | + _getPublishAudioPath(_param) { | ||
| 1896 | + if (_audio_ape) { | ||
| 1897 | + return _audio_ape.getAudioPublishPath(_param); | ||
| 1898 | + } | ||
| 1899 | + } | ||
| 1900 | + | ||
| 1901 | + _getAudioAllChannelInfo(_param) { | ||
| 1902 | + if (_audio_ape) { | ||
| 1903 | + return _audio_ape.getAllChannelInfo(_param); | ||
| 1904 | + } | ||
| 1905 | + } | ||
| 1906 | + | ||
| 1907 | + _publishAudio(_param) { | ||
| 1908 | + if (!_mcu.connected) { | ||
| 1909 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1910 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1911 | + } | ||
| 1912 | + if (_audio_ape) { | ||
| 1913 | + return _audio_ape.publishAudio(_param); | ||
| 1914 | + } | ||
| 1915 | + } | ||
| 1916 | + | ||
| 1917 | + _stopPublishAudio(_param) { | ||
| 1918 | + if (!_mcu.connected) { | ||
| 1919 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1920 | + return {"code": ApeConsts.RETURN_FAILED, "data": ""}; | ||
| 1921 | + } | ||
| 1922 | + if (_audio_ape) { | ||
| 1923 | + return _audio_ape.stopPublishAudio(_param); | ||
| 1924 | + } | ||
| 1925 | + } | ||
| 1926 | + | ||
| 1927 | + //WhiteBoardApe | ||
| 1928 | + // 添加标注,发送信息 | ||
| 1929 | + _sendInsertAnnotaion(_param) { | ||
| 1930 | + if (!_mcu.connected) { | ||
| 1931 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1932 | + return; | ||
| 1933 | + } | ||
| 1934 | + if (_whiteboard_ape) { | ||
| 1935 | + _whiteboard_ape.sendInsetAnnotaion(_param); | ||
| 1936 | + } | ||
| 1937 | + } | ||
| 1938 | + | ||
| 1939 | + //CursorApe | ||
| 1940 | + // 添加鼠标同步 | ||
| 1941 | + _sendInsertCursor(_param) { | ||
| 1942 | + if (!_mcu.connected) { | ||
| 1943 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1944 | + return; | ||
| 1945 | + } | ||
| 1946 | + if (_cursor_ape) { | ||
| 1947 | + _cursor_ape.sendInsertCursor(_param); | ||
| 1948 | + } | ||
| 1949 | + } | ||
| 1950 | + | ||
| 1951 | + //删除当前页面上的所有标注 | ||
| 1952 | + _sendDeleteCurPageAnnotation(_param) { | ||
| 1953 | + if (!_mcu.connected) { | ||
| 1954 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1955 | + return; | ||
| 1956 | + } | ||
| 1957 | + if (_whiteboard_ape) { | ||
| 1958 | + _whiteboard_ape.sendDeleteCurPageAnnotation(_param); | ||
| 1959 | + } | ||
| 1960 | + } | ||
| 1961 | + | ||
| 1962 | + //删除所有标注 | ||
| 1963 | + _sendDeleteAllAnnotation(_param) { | ||
| 1964 | + if (!_mcu.connected) { | ||
| 1965 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 1966 | + return; | ||
| 1967 | + } | ||
| 1968 | + if (_whiteboard_ape) { | ||
| 1969 | + _whiteboard_ape.sendDeleteAllAnnotation(_param); | ||
| 1970 | + } | ||
| 1971 | + } | ||
| 1972 | + | ||
| 1973 | + //返回上一步标注 | ||
| 1974 | + _sendGotoPrev(_param) { | ||
| 1975 | + if (_whiteboard_ape) { | ||
| 1976 | + _whiteboard_ape.sendGotoPrev(_param); | ||
| 1977 | + } | ||
| 1978 | + } | ||
| 1979 | + | ||
| 1980 | + //DocApe | ||
| 1981 | + //获取文档的所有资源地址 | ||
| 1982 | + _getDocFullAddress(_param) { | ||
| 1983 | + if (_doc_ape) { | ||
| 1984 | + return _doc_ape.getDocFullAddress(_param); | ||
| 1985 | + } else { | ||
| 1986 | + loger.error("文档模块还没有创建无法获取"); | ||
| 1987 | + return {"code": ApeConsts.RETURN_FAILED, "data": "文档模块还没有创建无法获取"}; | ||
| 1988 | + } | ||
| 1989 | + } | ||
| 1990 | + | ||
| 1991 | + //获取文档完整路径 | ||
| 1992 | + _getDocImageFullPath(_param) { | ||
| 1993 | + if (_doc_ape) { | ||
| 1994 | + return _doc_ape.getDocImageFullPath(_param); | ||
| 1995 | + } else { | ||
| 1996 | + loger.error("文档模块还没有创建无法获取"); | ||
| 1997 | + return []; | ||
| 1998 | + } | ||
| 1999 | + } | ||
| 2000 | + | ||
| 2001 | + _getDocPDFFullPath(_param) { | ||
| 2002 | + if (_doc_ape) { | ||
| 2003 | + return _doc_ape.getDocPDFFullPath(_param); | ||
| 2004 | + } else { | ||
| 2005 | + loger.error("文档模块还没有创建,无法获取"); | ||
| 2006 | + return []; | ||
| 2007 | + } | ||
| 2008 | + } | ||
| 2009 | + | ||
| 2010 | + //上传文档 | ||
| 2011 | + _sendDocumentUpload(_param) { | ||
| 2012 | + if (!_mcu.connected) { | ||
| 2013 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2014 | + return; | ||
| 2015 | + } | ||
| 2016 | + if (_doc_ape) { | ||
| 2017 | + _doc_ape.documentUpload(_param); | ||
| 2018 | + } | ||
| 2019 | + } | ||
| 2020 | + | ||
| 2021 | + //切换文档 | ||
| 2022 | + _sendDocumentSwitchDoc(_param) { | ||
| 2023 | + if (!_mcu.connected) { | ||
| 2024 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2025 | + return; | ||
| 2026 | + } | ||
| 2027 | + if (_doc_ape) { | ||
| 2028 | + _doc_ape.documentSwitchDoc(_param); | ||
| 2029 | + } | ||
| 2030 | + } | ||
| 2031 | + | ||
| 2032 | + //操作文档(翻页) | ||
| 2033 | + _sendDocumentSwitchPage(_param) { | ||
| 2034 | + if (!_mcu.connected) { | ||
| 2035 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2036 | + return; | ||
| 2037 | + } | ||
| 2038 | + if (_doc_ape) { | ||
| 2039 | + _doc_ape.documentSwitchPage(_param); | ||
| 2040 | + } | ||
| 2041 | + } | ||
| 2042 | + | ||
| 2043 | + //操作文档(页码上的动画步骤操作) | ||
| 2044 | + _sendDocumentSwitchAnimation(_param) { | ||
| 2045 | + if (!_mcu.connected) { | ||
| 2046 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2047 | + return; | ||
| 2048 | + } | ||
| 2049 | + if (_doc_ape) { | ||
| 2050 | + _doc_ape.documentSwitchAnimation(_param); | ||
| 2051 | + } | ||
| 2052 | + } | ||
| 2053 | + | ||
| 2054 | + //操作文档(缩放、滚动...) | ||
| 2055 | + _sendDocumentCommand(_param) { | ||
| 2056 | + if (!_mcu.connected) { | ||
| 2057 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2058 | + return; | ||
| 2059 | + } | ||
| 2060 | + if (_doc_ape) { | ||
| 2061 | + _doc_ape.documentCommand(_param); | ||
| 2062 | + } | ||
| 2063 | + } | ||
| 2064 | + | ||
| 2065 | + //删除文档 | ||
| 2066 | + _sendDocumentDelete(_param) { | ||
| 2067 | + if (!_mcu.connected) { | ||
| 2068 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2069 | + return; | ||
| 2070 | + } | ||
| 2071 | + if (_doc_ape) { | ||
| 2072 | + _doc_ape.documentDelete(_param); | ||
| 2073 | + } | ||
| 2074 | + } | ||
| 2075 | + | ||
| 2076 | + //删除所有文档 | ||
| 2077 | + _documentDeleteAll(_param) { | ||
| 2078 | + if (!_mcu.connected) { | ||
| 2079 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2080 | + return; | ||
| 2081 | + } | ||
| 2082 | + if (_doc_ape) { | ||
| 2083 | + _doc_ape.documentDeleteAll(_param); | ||
| 2084 | + } | ||
| 2085 | + } | ||
| 2086 | + | ||
| 2087 | + //// 文档变更,白板也需要做处理 | ||
| 2088 | + docUpdateHandler(_data) { | ||
| 2089 | + if (!_mcu.connected && !GlobalConfig.isRecordPlayBack) { | ||
| 2090 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2091 | + return; | ||
| 2092 | + } | ||
| 2093 | + //loger.log('Doc UpdateId ->'); | ||
| 2094 | + //loger.log(_data); | ||
| 2095 | + if (_whiteboard_ape) { | ||
| 2096 | + _whiteboard_ape.docUpdateHandler(_data); | ||
| 2097 | + } | ||
| 2098 | + } | ||
| 2099 | + | ||
| 2100 | + //文档删除,白板也需要做处理 | ||
| 2101 | + docDeleteHandler(_data) { | ||
| 2102 | + if (_whiteboard_ape) { | ||
| 2103 | + _whiteboard_ape.docDeleteHandler(_data); | ||
| 2104 | + } | ||
| 2105 | + } | ||
| 2106 | + | ||
| 2107 | + //文档加入频道成功,同步到MCU服务器上的数据 | ||
| 2108 | + docJoinChannelSuccess() { | ||
| 2109 | + loger.log("docJoinChannelSuccess->isHost=", GlobalConfig.isHost, "当前总人数:", GlobalConfig.rosterNumber, "sassDoclength=", GlobalConfig.docListPrepare.length); | ||
| 2110 | + //loger.log("docJoinChannelSuccess docListPrepare="); | ||
| 2111 | + //如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传 | ||
| 2112 | + if (GlobalConfig.docListPrepare && GlobalConfig.docListPrepare.length > 0) { | ||
| 2113 | + //如果当前身份是老师或者当前课堂内只有一个人,有权限同步文档到MCU | ||
| 2114 | + if (GlobalConfig.isHost || GlobalConfig.rosterNumber <= 1) { | ||
| 2115 | + for (let i = 0; i < GlobalConfig.docListPrepare.length; i++) { | ||
| 2116 | + let value = GlobalConfig.docListPrepare[i]; | ||
| 2117 | + if (value) { | ||
| 2118 | + //loger.log("判断是否需要把提前上传的文档上传到mcu", value); | ||
| 2119 | + let paramInfo = { | ||
| 2120 | + "pageNum": value.pdfSize, | ||
| 2121 | + "fileName": value.name, | ||
| 2122 | + "fileType": value.type, | ||
| 2123 | + "relativeUrl": value.relativeLocation, | ||
| 2124 | + "url": value.absoluteLocation, | ||
| 2125 | + "creatUserId": value.createUserID, | ||
| 2126 | + "docId": value.id, | ||
| 2127 | + "md5": value.MD5, | ||
| 2128 | + "visible": false | ||
| 2129 | + }; | ||
| 2130 | + this._sendDocumentUpload(paramInfo); | ||
| 2131 | + } | ||
| 2132 | + } | ||
| 2133 | + } | ||
| 2134 | + } | ||
| 2135 | + } | ||
| 2136 | + | ||
| 2137 | + //媒体共享模块的接口 | ||
| 2138 | + //上传 | ||
| 2139 | + _sendMediaSharedUpload(_param) { | ||
| 2140 | + if (!_mcu.connected) { | ||
| 2141 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2142 | + return; | ||
| 2143 | + } | ||
| 2144 | + if (_mediaShareApe) { | ||
| 2145 | + _mediaShareApe.mediaSharedUpload(_param); | ||
| 2146 | + } | ||
| 2147 | + } | ||
| 2148 | + | ||
| 2149 | + //音乐共享模块的接口 | ||
| 2150 | + //上传 | ||
| 2151 | + _sendMusicSharedUpload(_param) { | ||
| 2152 | + if (!_mcu.connected) { | ||
| 2153 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2154 | + return; | ||
| 2155 | + } | ||
| 2156 | + if (_musicShareApe) { | ||
| 2157 | + _musicShareApe.musicSharedUpload(_param); | ||
| 2158 | + } | ||
| 2159 | + } | ||
| 2160 | + | ||
| 2161 | + //Sass删除媒体文件数据 | ||
| 2162 | + _sassDeletMediaShare(_param) { | ||
| 2163 | + if (!_mcu.connected) { | ||
| 2164 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2165 | + return; | ||
| 2166 | + } | ||
| 2167 | + | ||
| 2168 | + //判断传入的参数是否存在 | ||
| 2169 | + if (_param == null || EngineUtils.isEmptyObject(_param)) { | ||
| 2170 | + loger.error('删除媒体文件失败->参数错误', _param); | ||
| 2171 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_MEDIASHARE_DELETE_FAILED_PARAM); | ||
| 2172 | + return; | ||
| 2173 | + } | ||
| 2174 | + //判断必要的参数字段值 | ||
| 2175 | + if (_param.itemIdx == null || isNaN(_param.itemIdx) || _param.fileId == null || _param.fileId == "") { | ||
| 2176 | + loger.error('删除媒体文件失败->', _param); | ||
| 2177 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_MEDIASHARE_DELETE_FAILED_PARAM); | ||
| 2178 | + return; | ||
| 2179 | + } | ||
| 2180 | + loger.log('删除媒体文件->', _param); | ||
| 2181 | + | ||
| 2182 | + if (_sass) { | ||
| 2183 | + _sass.sassDeletMediaShare(_param); | ||
| 2184 | + } | ||
| 2185 | + } | ||
| 2186 | + | ||
| 2187 | + // 删除Music | ||
| 2188 | + _sassDeletMusicShare(_param) { | ||
| 2189 | + if (!_mcu.connected) { | ||
| 2190 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2191 | + return; | ||
| 2192 | + } | ||
| 2193 | + | ||
| 2194 | + //判断传入的参数是否存在 | ||
| 2195 | + if (_param == null || EngineUtils.isEmptyObject(_param)) { | ||
| 2196 | + loger.error('删除媒体文件失败->参数错误', _param); | ||
| 2197 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_MUSICSHARE_DELETE_FAILED_PARAM); | ||
| 2198 | + return; | ||
| 2199 | + } | ||
| 2200 | + //判断必要的参数字段值 | ||
| 2201 | + if (_param.itemIdx == null || isNaN(_param.itemIdx) || _param.fileId == null || _param.fileId == "") { | ||
| 2202 | + loger.error('删除媒体文件失败->', _param); | ||
| 2203 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_MUSICSHARE_DELETE_FAILED_PARAM); | ||
| 2204 | + return; | ||
| 2205 | + } | ||
| 2206 | + loger.log('删除媒体文件->', _param); | ||
| 2207 | + | ||
| 2208 | + if (_sass) { | ||
| 2209 | + _sass.sassDeletMusicShare(_param); | ||
| 2210 | + } | ||
| 2211 | + } | ||
| 2212 | + | ||
| 2213 | + //删除媒体 | ||
| 2214 | + _sendMediaSharedDelete(_param) { | ||
| 2215 | + if (!_mcu.connected) { | ||
| 2216 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2217 | + return; | ||
| 2218 | + } | ||
| 2219 | + if (_mediaShareApe) { | ||
| 2220 | + _mediaShareApe.mediaSharedDelete(_param); | ||
| 2221 | + } | ||
| 2222 | + } | ||
| 2223 | + | ||
| 2224 | + //删除媒体 | ||
| 2225 | + _sendMusicSharedDelete(_param) { | ||
| 2226 | + if (!_mcu.connected) { | ||
| 2227 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2228 | + return; | ||
| 2229 | + } | ||
| 2230 | + if (_musicShareApe) { | ||
| 2231 | + _musicShareApe.musicSharedDelete(_param); | ||
| 2232 | + } | ||
| 2233 | + } | ||
| 2234 | + | ||
| 2235 | + //音乐更新 | ||
| 2236 | + _sendMusicSharedUpdate(_param) { | ||
| 2237 | + if (!_mcu.connected) { | ||
| 2238 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2239 | + return; | ||
| 2240 | + } | ||
| 2241 | + if (_musicShareApe) { | ||
| 2242 | + _musicShareApe.musicSharedUpdate(_param); | ||
| 2243 | + } | ||
| 2244 | + } | ||
| 2245 | + | ||
| 2246 | + //音乐播放 | ||
| 2247 | + _sendMusicSharedPlay(_param) { | ||
| 2248 | + if (!_mcu.connected) { | ||
| 2249 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2250 | + return; | ||
| 2251 | + } | ||
| 2252 | + if (_musicShareApe) { | ||
| 2253 | + _musicShareApe.musicSharedPlay(_param); | ||
| 2254 | + } | ||
| 2255 | + } | ||
| 2256 | + | ||
| 2257 | + //音乐停止 | ||
| 2258 | + _sendMusicSharedStop(_param) { | ||
| 2259 | + if (!_mcu.connected) { | ||
| 2260 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2261 | + return; | ||
| 2262 | + } | ||
| 2263 | + if (_musicShareApe) { | ||
| 2264 | + _musicShareApe.musicSharedStop(_param); | ||
| 2265 | + } | ||
| 2266 | + } | ||
| 2267 | + | ||
| 2268 | + //更新媒体文件的状态信息 | ||
| 2269 | + _sendMediaSharedUpdate(_param) { | ||
| 2270 | + if (!_mcu.connected) { | ||
| 2271 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2272 | + return; | ||
| 2273 | + } | ||
| 2274 | + if (_mediaShareApe) { | ||
| 2275 | + _mediaShareApe.mediaSharedUpdate(_param); | ||
| 2276 | + } | ||
| 2277 | + } | ||
| 2278 | + | ||
| 2279 | + //播放 | ||
| 2280 | + _sendMediaSharedPlay(_param) { | ||
| 2281 | + if (!_mcu.connected) { | ||
| 2282 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2283 | + return; | ||
| 2284 | + } | ||
| 2285 | + if (_mediaShareApe) { | ||
| 2286 | + _mediaShareApe.mediaSharedPlay(_param); | ||
| 2287 | + } | ||
| 2288 | + } | ||
| 2289 | + | ||
| 2290 | + //停止 | ||
| 2291 | + | ||
| 2292 | + _sendMediaSharedStop(_param) { | ||
| 2293 | + if (!_mcu.connected) { | ||
| 2294 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2295 | + return; | ||
| 2296 | + } | ||
| 2297 | + if (_mediaShareApe) { | ||
| 2298 | + _mediaShareApe.mediaSharedStop(_param); | ||
| 2299 | + } | ||
| 2300 | + } | ||
| 2301 | + | ||
| 2302 | + //音乐共享模块加入频道成功,同步到MCU服务器上的数据 | ||
| 2303 | + musicShareApeJoinChannelSuccess() { | ||
| 2304 | + loger.log("伴音MUSIC模块加入频道成功->isHost=", GlobalConfig.isHost, "length=", GlobalConfig.musicListPrepare.length); | ||
| 2305 | + console.log("伴音MUSIC模块共享模数据->", GlobalConfig.musicListPrepare); | ||
| 2306 | + //如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传 | ||
| 2307 | + if (GlobalConfig.isHost && GlobalConfig.musicListPrepare.length > 0) { | ||
| 2308 | + for (let i = 0; i < GlobalConfig.musicListPrepare.length; i++) { | ||
| 2309 | + let value = GlobalConfig.musicListPrepare[i]; | ||
| 2310 | + if (value) { | ||
| 2311 | + let paramInfo = { | ||
| 2312 | + "status": 0, | ||
| 2313 | + "creatUserId": value.creatUserId, | ||
| 2314 | + "creatUserName": value.createUserName, | ||
| 2315 | + "url": value.url || value.absoluteLocation,//伴音上传的接口有差异,课堂内上传返回的是url字段,后台带入的字段是absoluteLocation | ||
| 2316 | + "fileType": value.type, | ||
| 2317 | + "fileId": "" + value.id, | ||
| 2318 | + "fileName": value.name, | ||
| 2319 | + "seek": 0 | ||
| 2320 | + }; | ||
| 2321 | + this._sendMusicSharedUpload(paramInfo); | ||
| 2322 | + } | ||
| 2323 | + } | ||
| 2324 | + } | ||
| 2325 | + } | ||
| 2326 | + | ||
| 2327 | + //媒体共享模块加入频道成功,同步到MCU服务器上的数据 | ||
| 2328 | + mediaShareApeJoinChannelSuccess() { | ||
| 2329 | + loger.log("媒体共享模块加入频道成功->isHost=", GlobalConfig.isHost, "length=", GlobalConfig.sharedMediaList.length); | ||
| 2330 | + console.log("媒体共享模数据->", GlobalConfig.sharedMediaList); | ||
| 2331 | + //如果是主持人,那么需要判断一下文档模块同步的数据和从sass获取的文档数据是否相同,如果mcu服务器不存在的,需要上传 | ||
| 2332 | + if (GlobalConfig.isHost && GlobalConfig.sharedMediaList.length > 0) { | ||
| 2333 | + for (let i = 0; i < GlobalConfig.sharedMediaList.length; i++) { | ||
| 2334 | + let value = GlobalConfig.sharedMediaList[i]; | ||
| 2335 | + if (value) { | ||
| 2336 | + let paramInfo = { | ||
| 2337 | + "status": 0, | ||
| 2338 | + "creatUserId": value.creatUserId, | ||
| 2339 | + "creatUserName": value.createUserName, | ||
| 2340 | + "url": value.url, | ||
| 2341 | + "fileType": value.type, | ||
| 2342 | + "fileId": "" + value.id, | ||
| 2343 | + "fileName": value.name, | ||
| 2344 | + "seek": 0 | ||
| 2345 | + }; | ||
| 2346 | + this._sendMediaSharedUpload(paramInfo); | ||
| 2347 | + } | ||
| 2348 | + } | ||
| 2349 | + } | ||
| 2350 | + } | ||
| 2351 | + | ||
| 2352 | + //录制回放相关的处理------------------------------------------------ | ||
| 2353 | + //录制回放初始化 | ||
| 2354 | + _initRecordPlayback(_param) { | ||
| 2355 | + //{"classId":"1653304953","portal":"112.126.80.182:80","userRole":"normal","userId":0} | ||
| 2356 | + if (_param == null) { | ||
| 2357 | + loger.error('录制回放初始化失败->参数错误'); | ||
| 2358 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_INIT_RECORD_PLAY_BACK_FAILED); | ||
| 2359 | + return; | ||
| 2360 | + } | ||
| 2361 | + //判断必要的参数字段值 | ||
| 2362 | + if (_param.classId == null || isNaN(_param.classId) || _param.portal == null || _param.portal == "") { | ||
| 2363 | + loger.error('录制回放初始化失败->', _param); | ||
| 2364 | + this._emit(MessageTypes.MCU_ERROR, MessageTypes.ERR_INIT_RECORD_PLAY_BACK_FAILED); | ||
| 2365 | + return; | ||
| 2366 | + } | ||
| 2367 | + loger.log('录制回放初始化->', _param); | ||
| 2368 | + | ||
| 2369 | + //保存参数 | ||
| 2370 | + GlobalConfig.isRecordPlayBack = true; //设置为录制回放状态 | ||
| 2371 | + GlobalConfig.classId = parseInt(_param.classId); | ||
| 2372 | + GlobalConfig.portal = _param.portal; | ||
| 2373 | + GlobalConfig.userRole = ApeConsts.normal; //*************很重要,录制回放的时候,身份模式是普通人******** | ||
| 2374 | + GlobalConfig.userId = _param.userId || "0"; | ||
| 2375 | + GlobalConfig.userName = _param.userName || ""; | ||
| 2376 | + | ||
| 2377 | + //获取课堂最完整的数据,录制回放需要获取课堂数据 | ||
| 2378 | + if (_sass) { | ||
| 2379 | + _sass.getClassParam(); | ||
| 2380 | + } | ||
| 2381 | + } | ||
| 2382 | + | ||
| 2383 | + //开始录制回放 | ||
| 2384 | + _startRecordPlayback(_param) { | ||
| 2385 | + if (_recordPlayback) { | ||
| 2386 | + _recordPlayback.startRecordPlayback(_param); | ||
| 2387 | + } | ||
| 2388 | + } | ||
| 2389 | + | ||
| 2390 | + //停止录制回放 | ||
| 2391 | + _stopRecordPlayback(_param) { | ||
| 2392 | + if (_recordPlayback) { | ||
| 2393 | + _recordPlayback.stopRecordPlayback(_param); | ||
| 2394 | + } | ||
| 2395 | + } | ||
| 2396 | + | ||
| 2397 | + //暂停录制回放 | ||
| 2398 | + _pauseRecordPlayback(_param) { | ||
| 2399 | + if (_recordPlayback) { | ||
| 2400 | + _recordPlayback.pauseRecordPlayback(_param); | ||
| 2401 | + } | ||
| 2402 | + } | ||
| 2403 | + | ||
| 2404 | + //seek录制回放 | ||
| 2405 | + _seekRecordPlayback(_param) { | ||
| 2406 | + if (_recordPlayback) { | ||
| 2407 | + _recordPlayback.seekRecordPlayback(_param); | ||
| 2408 | + } | ||
| 2409 | + } | ||
| 2410 | + | ||
| 2411 | + //录制回放状态更新 | ||
| 2412 | + _recordPlaybackClearDataHandler(_param) { | ||
| 2413 | + loger.log("录制回放状态更新->") | ||
| 2414 | + if (_doc_ape) { | ||
| 2415 | + _doc_ape.clearData(); | ||
| 2416 | + } | ||
| 2417 | + if (_whiteboard_ape) { | ||
| 2418 | + _whiteboard_ape.clearData(); | ||
| 2419 | + } | ||
| 2420 | + if (_video_ape) { | ||
| 2421 | + _video_ape.clearData(); | ||
| 2422 | + } | ||
| 2423 | + } | ||
| 2424 | + | ||
| 2425 | + //录制回放加入 课堂成功 | ||
| 2426 | + _joinRecordPlaybackSuccessHandler(_data) { | ||
| 2427 | + loger.log('加入录制回放成功.'); | ||
| 2428 | + GlobalConfig.setCurrentStatus(GlobalConfig.statusCode_2); | ||
| 2429 | + | ||
| 2430 | + //返回给客户端初始化成功的数据 | ||
| 2431 | + let joinClassSuccessCallBackData = {}; | ||
| 2432 | + | ||
| 2433 | + joinClassSuccessCallBackData.isRecordPlayBack = GlobalConfig.isRecordPlayBack; | ||
| 2434 | + | ||
| 2435 | + joinClassSuccessCallBackData.DOCServerIP = GlobalConfig.DOCServerIP; | ||
| 2436 | + joinClassSuccessCallBackData.DOCServerPort = GlobalConfig.DOCServerPort; | ||
| 2437 | + | ||
| 2438 | + joinClassSuccessCallBackData.classStatus = GlobalConfig.classStatus; | ||
| 2439 | + joinClassSuccessCallBackData.classId = GlobalConfig.classId; | ||
| 2440 | + joinClassSuccessCallBackData.className = GlobalConfig.className; | ||
| 2441 | + joinClassSuccessCallBackData.h5Module = GlobalConfig.h5Module; | ||
| 2442 | + joinClassSuccessCallBackData.isHost = GlobalConfig.isHost; // | ||
| 2443 | + joinClassSuccessCallBackData.maxAudioChannels = GlobalConfig.maxAudioChannels; | ||
| 2444 | + joinClassSuccessCallBackData.maxVideoChannels = GlobalConfig.maxVideoChannels; | ||
| 2445 | + joinClassSuccessCallBackData.maxMediaChannels = GlobalConfig.maxMediaChannels; | ||
| 2446 | + | ||
| 2447 | + joinClassSuccessCallBackData.mcuDelay = GlobalConfig.mcuDelay; | ||
| 2448 | + | ||
| 2449 | + joinClassSuccessCallBackData.msType = GlobalConfig.msType; | ||
| 2450 | + joinClassSuccessCallBackData.nodeId = GlobalConfig.nodeId; | ||
| 2451 | + joinClassSuccessCallBackData.password = GlobalConfig.password; | ||
| 2452 | + joinClassSuccessCallBackData.passwordRequired = GlobalConfig.passwordRequired; // 老师的默认是true | ||
| 2453 | + //GlobalConfig.passwordRequired 老师的默认是true | ||
| 2454 | + //GlobalConfig.portal=_data.portal; | ||
| 2455 | + joinClassSuccessCallBackData.role = GlobalConfig.role; | ||
| 2456 | + joinClassSuccessCallBackData.siteId = GlobalConfig.siteId; | ||
| 2457 | + joinClassSuccessCallBackData.topNodeID = GlobalConfig.topNodeID; | ||
| 2458 | + joinClassSuccessCallBackData.userId = GlobalConfig.userId; | ||
| 2459 | + joinClassSuccessCallBackData.userName = GlobalConfig.userName; | ||
| 2460 | + joinClassSuccessCallBackData.userRole = GlobalConfig.userRole; | ||
| 2461 | + joinClassSuccessCallBackData.userType = GlobalConfig.userType; | ||
| 2462 | + | ||
| 2463 | + joinClassSuccessCallBackData.siteId = GlobalConfig.siteId; | ||
| 2464 | + joinClassSuccessCallBackData.classId = GlobalConfig.classId; | ||
| 2465 | + joinClassSuccessCallBackData.userRole = GlobalConfig.userRole; | ||
| 2466 | + joinClassSuccessCallBackData.userId = GlobalConfig.userId; | ||
| 2467 | + joinClassSuccessCallBackData.passwordRequired = GlobalConfig.passwordRequired; | ||
| 2468 | + joinClassSuccessCallBackData.classType = GlobalConfig.classType || ApeConsts.CLASS_TYPE_1; | ||
| 2469 | + | ||
| 2470 | + joinClassSuccessCallBackData.country = GlobalConfig.country; //国家 | ||
| 2471 | + joinClassSuccessCallBackData.city = GlobalConfig.city; //城市 | ||
| 2472 | + joinClassSuccessCallBackData.province = GlobalConfig.province; //服务商 | ||
| 2473 | + joinClassSuccessCallBackData.isp = GlobalConfig.isp; //服务商 | ||
| 2474 | + | ||
| 2475 | + joinClassSuccessCallBackData.classTimestamp = GlobalConfig.classTimestamp; //课堂进行的累积时间 | ||
| 2476 | + joinClassSuccessCallBackData.recordTimestamp = GlobalConfig.recordTimestamp; //录制累积的总时间 | ||
| 2477 | + joinClassSuccessCallBackData.recordPlaybackMaxTime = GlobalConfig.recordPlaybackMaxTime; //录制回放的总时间 | ||
| 2478 | + | ||
| 2479 | + joinClassSuccessCallBackData.fps = GlobalConfig.fps; | ||
| 2480 | + joinClassSuccessCallBackData.gop = GlobalConfig.gop; | ||
| 2481 | + joinClassSuccessCallBackData.videoQuality = GlobalConfig.videoQuality; | ||
| 2482 | + | ||
| 2483 | + joinClassSuccessCallBackData.ssTunnelAppURL = GlobalConfig.ssTunnelAppURL; | ||
| 2484 | + joinClassSuccessCallBackData.currentSceneTableId = GlobalConfig.currentSceneTableId; //文档区域的模块显示 | ||
| 2485 | + joinClassSuccessCallBackData.serverAndLoacTimeDistanc = GlobalConfig.serverAndLoacTimeDistanc; | ||
| 2486 | + | ||
| 2487 | + joinClassSuccessCallBackData.deviceType = GlobalConfig.deviceType; | ||
| 2488 | + joinClassSuccessCallBackData.language = GlobalConfig.language; | ||
| 2489 | + joinClassSuccessCallBackData.explorer = GlobalConfig.explorer; | ||
| 2490 | + joinClassSuccessCallBackData.explorerVersion = GlobalConfig.explorerVersion; | ||
| 2491 | + joinClassSuccessCallBackData.os = GlobalConfig.os; | ||
| 2492 | + | ||
| 2493 | + loger.log(joinClassSuccessCallBackData); | ||
| 2494 | + //和加入课堂成功使用同样的消息处理 | ||
| 2495 | + this._emit(MessageTypes.CLASS_JOIN_SUCCESS, joinClassSuccessCallBackData); | ||
| 2496 | + } | ||
| 2497 | + | ||
| 2498 | + // //答题卡 | ||
| 2499 | + _creatQuestion(_param) { | ||
| 2500 | + if (!_mcu.connected) { | ||
| 2501 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2502 | + return; | ||
| 2503 | + } | ||
| 2504 | + if (_questionApe) { | ||
| 2505 | + _questionApe.creatQuestion(_param); | ||
| 2506 | + } | ||
| 2507 | + } | ||
| 2508 | + | ||
| 2509 | + _getQuestion(_param) { | ||
| 2510 | + if (!_mcu.connected) { | ||
| 2511 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2512 | + return; | ||
| 2513 | + } | ||
| 2514 | + if (_questionApe) { | ||
| 2515 | + _questionApe.getQuestion(_param); | ||
| 2516 | + } | ||
| 2517 | + } | ||
| 2518 | + | ||
| 2519 | + _getQuestionResult(_param) { | ||
| 2520 | + if (!_mcu.connected) { | ||
| 2521 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2522 | + return; | ||
| 2523 | + } | ||
| 2524 | + if (_questionApe) { | ||
| 2525 | + _questionApe.getQuestionResult(_param); | ||
| 2526 | + } | ||
| 2527 | + } | ||
| 2528 | + | ||
| 2529 | + _stopQuestion(_param) { | ||
| 2530 | + if (!_mcu.connected) { | ||
| 2531 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2532 | + return; | ||
| 2533 | + } | ||
| 2534 | + if (_questionApe) { | ||
| 2535 | + _questionApe.stopQuestion(_param); | ||
| 2536 | + } | ||
| 2537 | + } | ||
| 2538 | + | ||
| 2539 | + _sendAnswer(_param) { | ||
| 2540 | + if (!_mcu.connected) { | ||
| 2541 | + loger.warn(GlobalConfig.getCurrentStatus()); | ||
| 2542 | + return; | ||
| 2543 | + } | ||
| 2544 | + if (_questionApe) { | ||
| 2545 | + _questionApe.sendAnswer(_param); | ||
| 2546 | + } | ||
| 2547 | + } | ||
| 2548 | + | ||
| 2549 | +} | ||
| 2550 | + |
| @@ -376,6 +376,14 @@ GlobalConfig.rtmpPullList = []; //从Sass获取的rtmp拉流地址集合 | @@ -376,6 +376,14 @@ GlobalConfig.rtmpPullList = []; //从Sass获取的rtmp拉流地址集合 | ||
| 376 | GlobalConfig.hlsPullList = []; //从sasss获取的hls拉流服务器地址集合 | 376 | GlobalConfig.hlsPullList = []; //从sasss获取的hls拉流服务器地址集合 |
| 377 | GlobalConfig.rsList = []; //录制回放中视频hls点播地址 | 377 | GlobalConfig.rsList = []; //录制回放中视频hls点播地址 |
| 378 | 378 | ||
| 379 | +//从Sass获取的数据 | ||
| 380 | +GlobalConfig.mcuListFromSass = []; //录制服务器地址集合 | ||
| 381 | +GlobalConfig.msListFromSass = []; //从Sass获取的ms推流地址集合,也可以拉流 | ||
| 382 | +GlobalConfig.rtmpPullListFromSass = []; //从Sass获取的rtmp拉流地址集合 | ||
| 383 | +GlobalConfig.hlsPullListFromSass = []; //从sasss获取的hls拉流服务器地址集合 | ||
| 384 | +GlobalConfig.rsListFromSass = []; //录制回放中视频hls点播地址 | ||
| 385 | + | ||
| 386 | + | ||
| 379 | //根据userIP从server获取的数据 | 387 | //根据userIP从server获取的数据 |
| 380 | GlobalConfig.mcuListFromServer = []; //根据userIP从server获取的mcu列表 | 388 | GlobalConfig.mcuListFromServer = []; //根据userIP从server获取的mcu列表 |
| 381 | GlobalConfig.msListFromServer = []; //根据userIP从server获取的ms列表 | 389 | GlobalConfig.msListFromServer = []; //根据userIP从server获取的ms列表 |
| @@ -387,8 +395,8 @@ GlobalConfig.rsPullListFromServer = []; //根据userIP从server获取的录制 | @@ -387,8 +395,8 @@ GlobalConfig.rsPullListFromServer = []; //根据userIP从server获取的录制 | ||
| 387 | GlobalConfig.mcuListFinal = []; //最终选择的MCU集合 | 395 | GlobalConfig.mcuListFinal = []; //最终选择的MCU集合 |
| 388 | GlobalConfig.msListFinal = []; //最终选择的MS 推流地址集合 | 396 | GlobalConfig.msListFinal = []; //最终选择的MS 推流地址集合 |
| 389 | GlobalConfig.rtmpPullListFinal = []; //最终选择的RTMP推流地址集合 | 397 | GlobalConfig.rtmpPullListFinal = []; //最终选择的RTMP推流地址集合 |
| 390 | -GlobalConfig.hlsListFinal = []; //最终选择的HLS拉流地址集合 | ||
| 391 | -GlobalConfig.rsListFinal = []; //最终选择的录制回放HLS拉流地址集合 | 398 | +GlobalConfig.hlsPullListFinal = []; //最终选择的HLS拉流地址集合 |
| 399 | +GlobalConfig.rsPullListFinal = []; //最终选择的录制回放HLS拉流地址集合 | ||
| 392 | 400 | ||
| 393 | 401 | ||
| 394 | 402 |
| @@ -8,7 +8,7 @@ import Loger from 'Loger'; | @@ -8,7 +8,7 @@ import Loger from 'Loger'; | ||
| 8 | import MD5 from "md5"; | 8 | import MD5 from "md5"; |
| 9 | import iphunter from 'iphunter'; | 9 | import iphunter from 'iphunter'; |
| 10 | import fetchJsonp from 'fetch-jsonp'; | 10 | import fetchJsonp from 'fetch-jsonp'; |
| 11 | -import Server from "config/Server"; | 11 | +import ServerConfig from "config/ServerConfig"; |
| 12 | 12 | ||
| 13 | // 日志对象 | 13 | // 日志对象 |
| 14 | const loger = Loger.getLoger('IpManager'); | 14 | const loger = Loger.getLoger('IpManager'); |
| @@ -47,10 +47,11 @@ class IpManager extends Emiter { | @@ -47,10 +47,11 @@ class IpManager extends Emiter { | ||
| 47 | }) | 47 | }) |
| 48 | .then(ret => { | 48 | .then(ret => { |
| 49 | if (ret) { | 49 | if (ret) { |
| 50 | - Server.serverListData=ret||{}; | 50 | + //ServerConfig.serverListData=ret||{}; |
| 51 | serverInfo.data=ret; | 51 | serverInfo.data=ret; |
| 52 | + serverInfo.ret=1; | ||
| 52 | } | 53 | } |
| 53 | - loger.log('获取Server信息->完成->', ret); | 54 | + loger.log('获取Server信息->完成->'); |
| 54 | if (_callback) { | 55 | if (_callback) { |
| 55 | _callback(serverInfo); | 56 | _callback(serverInfo); |
| 56 | } | 57 | } |
| @@ -62,6 +63,7 @@ class IpManager extends Emiter { | @@ -62,6 +63,7 @@ class IpManager extends Emiter { | ||
| 62 | } | 63 | } |
| 63 | }); | 64 | }); |
| 64 | } | 65 | } |
| 66 | + | ||
| 65 | //根据userIp获取ip相关的信息,参数是userIp | 67 | //根据userIp获取ip相关的信息,参数是userIp |
| 66 | getUserIpInfo(token, userIp, _callback, _timeOutDelay) { | 68 | getUserIpInfo(token, userIp, _callback, _timeOutDelay) { |
| 67 | let userIpInfo = { | 69 | let userIpInfo = { |
| @@ -47,7 +47,8 @@ class MediaModule { | @@ -47,7 +47,8 @@ class MediaModule { | ||
| 47 | path = "http://" + GlobalConfig.MS_PLAY_HLS_IP | 47 | path = "http://" + GlobalConfig.MS_PLAY_HLS_IP |
| 48 | + port + "/live/" | 48 | + port + "/live/" |
| 49 | + _param.streamId | 49 | + _param.streamId |
| 50 | - + "/"+fileName;// | 50 | + + ".m3u8";// |
| 51 | + //+ "/"+fileName;// | ||
| 51 | 52 | ||
| 52 | 53 | ||
| 53 | } else { | 54 | } else { |
src/config/ServerConfig.js
0 → 100644
| 1 | +/* | ||
| 2 | + * 服务配置 | ||
| 3 | + * */ | ||
| 4 | +import Loger from 'Loger'; | ||
| 5 | +import ApeConsts from "apes/ApeConsts"; | ||
| 6 | +let loger = Loger.getLoger('ServerConfig'); | ||
| 7 | +import EngineUtils from 'EngineUtils'; | ||
| 8 | + | ||
| 9 | +class ServerConfig { | ||
| 10 | + constructor() { | ||
| 11 | + | ||
| 12 | + } | ||
| 13 | + static set serverList(value){ | ||
| 14 | + this.serverListData=value||{}; | ||
| 15 | + } | ||
| 16 | + static get serverList(){ | ||
| 17 | + return this.serverListData; | ||
| 18 | + | ||
| 19 | + /* return { | ||
| 20 | + "MS":{ | ||
| 21 | + "共享地址": [ | ||
| 22 | + { | ||
| 23 | + "ip": "106.3.130.98", | ||
| 24 | + "name": "BGP多线3" | ||
| 25 | + }, | ||
| 26 | + { | ||
| 27 | + "ip": "123.56.75.60", | ||
| 28 | + "name": "BGP多线4" | ||
| 29 | + }, | ||
| 30 | + { | ||
| 31 | + "ip": "221.228.109.123", | ||
| 32 | + "name": "无锡" | ||
| 33 | + }, | ||
| 34 | + { | ||
| 35 | + "ip": "qims.3mang.com", | ||
| 36 | + "name": "全球通-备" | ||
| 37 | + }, | ||
| 38 | + { | ||
| 39 | + "ip": "liantong.ms.3mang.com", | ||
| 40 | + "name": "联通专线" | ||
| 41 | + }, | ||
| 42 | + { | ||
| 43 | + "ip": "yidong.ms.3mang.com", | ||
| 44 | + "name": "移动专线" | ||
| 45 | + }, | ||
| 46 | + { | ||
| 47 | + "ip": "dianxin.ms.3mang.com", | ||
| 48 | + "name": "电信专线" | ||
| 49 | + }, | ||
| 50 | + { | ||
| 51 | + "ip": "103.235.232.128", | ||
| 52 | + "name": "BGP多线2" | ||
| 53 | + }, | ||
| 54 | + { | ||
| 55 | + "ip": "lanxms.3mang.com", | ||
| 56 | + "name": "国内专线" | ||
| 57 | + }, | ||
| 58 | + { | ||
| 59 | + "ip": "116.213.102.217", | ||
| 60 | + "name": "BGP多线1" | ||
| 61 | + } | ||
| 62 | + ], | ||
| 63 | + "局域网": [ | ||
| 64 | + { | ||
| 65 | + "ip": "106.3.130.98", | ||
| 66 | + "name": "BGP多线3" | ||
| 67 | + }, | ||
| 68 | + { | ||
| 69 | + "ip": "123.56.75.60", | ||
| 70 | + "name": "BGP多线4" | ||
| 71 | + }, | ||
| 72 | + { | ||
| 73 | + "ip": "221.228.109.123", | ||
| 74 | + "name": "无锡" | ||
| 75 | + }, | ||
| 76 | + { | ||
| 77 | + "ip": "qims.3mang.com", | ||
| 78 | + "name": "全球通-备" | ||
| 79 | + }, | ||
| 80 | + { | ||
| 81 | + "ip": "liantong.ms.3mang.com", | ||
| 82 | + "name": "联通专线" | ||
| 83 | + }, | ||
| 84 | + { | ||
| 85 | + "ip": "yidong.ms.3mang.com", | ||
| 86 | + "name": "移动专线" | ||
| 87 | + }, | ||
| 88 | + { | ||
| 89 | + "ip": "dianxin.ms.3mang.com", | ||
| 90 | + "name": "电信专线" | ||
| 91 | + }, | ||
| 92 | + { | ||
| 93 | + "ip": "103.235.232.128", | ||
| 94 | + "name": "BGP多线2" | ||
| 95 | + }, | ||
| 96 | + { | ||
| 97 | + "ip": "lanxms.3mang.com", | ||
| 98 | + "name": "国内专线" | ||
| 99 | + }, | ||
| 100 | + { | ||
| 101 | + "ip": "116.213.102.217", | ||
| 102 | + "name": "BGP多线1" | ||
| 103 | + } | ||
| 104 | + ], | ||
| 105 | + "中国": { | ||
| 106 | + "province": { | ||
| 107 | + "香港": [ | ||
| 108 | + { | ||
| 109 | + "ip": "bjms1.3mang.com", | ||
| 110 | + "name": "全球通" | ||
| 111 | + }, | ||
| 112 | + { | ||
| 113 | + "ip": "199.59.231.234", | ||
| 114 | + "name": "全球通香港" | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + "ip": "qims.3mang.com", | ||
| 118 | + "name": "全球通-备" | ||
| 119 | + } | ||
| 120 | + ], | ||
| 121 | + "台湾": [ | ||
| 122 | + { | ||
| 123 | + "ip": "bjms1.3mang.com", | ||
| 124 | + "name": "全球通" | ||
| 125 | + }, | ||
| 126 | + { | ||
| 127 | + "ip": "159.100.205.129", | ||
| 128 | + "name": "全球通台湾" | ||
| 129 | + }, | ||
| 130 | + { | ||
| 131 | + "ip": "qims.3mang.com", | ||
| 132 | + "name": "全球通-备" | ||
| 133 | + } | ||
| 134 | + ] | ||
| 135 | + }, | ||
| 136 | + "isp": { | ||
| 137 | + "鹏博士": [ | ||
| 138 | + { | ||
| 139 | + "ip": "124.192.148.139", | ||
| 140 | + "name": "鹏博士" | ||
| 141 | + }, | ||
| 142 | + { | ||
| 143 | + "ip": "123.56.75.60", | ||
| 144 | + "name": "BGP多线4" | ||
| 145 | + }, | ||
| 146 | + { | ||
| 147 | + "ip": "106.3.130.98", | ||
| 148 | + "name": "BGP多线3" | ||
| 149 | + }, | ||
| 150 | + { | ||
| 151 | + "ip": "lanxms.3mang.com", | ||
| 152 | + "name": "国内专线" | ||
| 153 | + }, | ||
| 154 | + { | ||
| 155 | + "ip": "qims.3mang.com", | ||
| 156 | + "name": "全球通-备" | ||
| 157 | + } | ||
| 158 | + ], | ||
| 159 | + "长城": [ | ||
| 160 | + { | ||
| 161 | + "ip": "124.192.148.139", | ||
| 162 | + "name": "鹏博士" | ||
| 163 | + }, | ||
| 164 | + { | ||
| 165 | + "ip": "123.56.75.60", | ||
| 166 | + "name": "BGP多线4" | ||
| 167 | + }, | ||
| 168 | + { | ||
| 169 | + "ip": "106.3.130.98", | ||
| 170 | + "name": "BGP多线3" | ||
| 171 | + }, | ||
| 172 | + { | ||
| 173 | + "ip": "lanxms.3mang.com", | ||
| 174 | + "name": "国内专线" | ||
| 175 | + }, | ||
| 176 | + { | ||
| 177 | + "ip": "qims.3mang.com", | ||
| 178 | + "name": "全球通-备" | ||
| 179 | + } | ||
| 180 | + ], | ||
| 181 | + "移动": [ | ||
| 182 | + { | ||
| 183 | + "ip": "yidong.ms.3mang.com", | ||
| 184 | + "name": "移动专线" | ||
| 185 | + }, | ||
| 186 | + { | ||
| 187 | + "ip": "116.213.102.217", | ||
| 188 | + "name": "BGP多线1" | ||
| 189 | + }, | ||
| 190 | + { | ||
| 191 | + "ip": "123.56.75.60", | ||
| 192 | + "name": "BGP多线4" | ||
| 193 | + }, | ||
| 194 | + { | ||
| 195 | + "ip": "103.235.232.128", | ||
| 196 | + "name": "BGP多线2" | ||
| 197 | + }, | ||
| 198 | + { | ||
| 199 | + "ip": "lanxms.3mang.com", | ||
| 200 | + "name": "国内专线" | ||
| 201 | + }, | ||
| 202 | + { | ||
| 203 | + "ip": "qims.3mang.com", | ||
| 204 | + "name": "全球通-备" | ||
| 205 | + } | ||
| 206 | + ], | ||
| 207 | + "电信": [ | ||
| 208 | + { | ||
| 209 | + "ip": "dianxin.ms.3mang.com", | ||
| 210 | + "name": "电信专线" | ||
| 211 | + }, | ||
| 212 | + { | ||
| 213 | + "ip": "116.213.102.217", | ||
| 214 | + "name": "BGP多线1" | ||
| 215 | + }, | ||
| 216 | + { | ||
| 217 | + "ip": "103.235.232.128", | ||
| 218 | + "name": "BGP多线2" | ||
| 219 | + }, | ||
| 220 | + { | ||
| 221 | + "ip": "123.56.75.60", | ||
| 222 | + "name": "BGP多线4" | ||
| 223 | + }, | ||
| 224 | + { | ||
| 225 | + "ip": "lanxms.3mang.com", | ||
| 226 | + "name": "国内专线" | ||
| 227 | + }, | ||
| 228 | + { | ||
| 229 | + "ip": "qims.3mang.com", | ||
| 230 | + "name": "全球通-备" | ||
| 231 | + } | ||
| 232 | + ], | ||
| 233 | + "联通": [ | ||
| 234 | + { | ||
| 235 | + "ip": "116.213.102.217", | ||
| 236 | + "name": "BGP多线1" | ||
| 237 | + }, | ||
| 238 | + { | ||
| 239 | + "ip": "103.235.232.128", | ||
| 240 | + "name": "BGP多线2" | ||
| 241 | + }, | ||
| 242 | + { | ||
| 243 | + "ip": "liantong.ms.3mang.com", | ||
| 244 | + "name": "联通专线" | ||
| 245 | + }, | ||
| 246 | + { | ||
| 247 | + "ip": "123.56.75.60", | ||
| 248 | + "name": "BGP多线4" | ||
| 249 | + }, | ||
| 250 | + { | ||
| 251 | + "ip": "106.3.130.98", | ||
| 252 | + "name": "BGP多线3" | ||
| 253 | + }, | ||
| 254 | + { | ||
| 255 | + "ip": "lanxms.3mang.com", | ||
| 256 | + "name": "国内专线" | ||
| 257 | + }, | ||
| 258 | + { | ||
| 259 | + "ip": "qims.3mang.com", | ||
| 260 | + "name": "全球通-备" | ||
| 261 | + } | ||
| 262 | + ] | ||
| 263 | + }, | ||
| 264 | + "default": [ | ||
| 265 | + { | ||
| 266 | + "ip": "106.3.130.98", | ||
| 267 | + "name": "BGP多线3" | ||
| 268 | + }, | ||
| 269 | + { | ||
| 270 | + "ip": "221.228.109.123", | ||
| 271 | + "name": "无锡" | ||
| 272 | + }, | ||
| 273 | + { | ||
| 274 | + "ip": "qims.3mang.com", | ||
| 275 | + "name": "全球通-备" | ||
| 276 | + }, | ||
| 277 | + { | ||
| 278 | + "ip": "liantong.ms.3mang.com", | ||
| 279 | + "name": "联通专线" | ||
| 280 | + }, | ||
| 281 | + { | ||
| 282 | + "ip": "yidong.ms.3mang.com", | ||
| 283 | + "name": "移动专线" | ||
| 284 | + }, | ||
| 285 | + { | ||
| 286 | + "ip": "dianxin.ms.3mang.com", | ||
| 287 | + "name": "电信专线" | ||
| 288 | + }, | ||
| 289 | + { | ||
| 290 | + "ip": "lanxms.3mang.com", | ||
| 291 | + "name": "国内专线" | ||
| 292 | + }, | ||
| 293 | + { | ||
| 294 | + "ip": "123.56.75.60", | ||
| 295 | + "name": "BGP多线4" | ||
| 296 | + }, | ||
| 297 | + { | ||
| 298 | + "ip": "103.235.232.128", | ||
| 299 | + "name": "BGP多线2" | ||
| 300 | + }, | ||
| 301 | + { | ||
| 302 | + "ip": "116.213.102.217", | ||
| 303 | + "name": "BGP多线1" | ||
| 304 | + } | ||
| 305 | + ] | ||
| 306 | + }, | ||
| 307 | + "美国": [ | ||
| 308 | + { | ||
| 309 | + "ip": "38.83.109.142", | ||
| 310 | + "name": "达拉斯" | ||
| 311 | + }, | ||
| 312 | + { | ||
| 313 | + "ip": "45.126.244.41", | ||
| 314 | + "name": "全球通达拉斯" | ||
| 315 | + }, | ||
| 316 | + { | ||
| 317 | + "ip": "185.114.76.243", | ||
| 318 | + "name": "全球通阿什本" | ||
| 319 | + }, | ||
| 320 | + { | ||
| 321 | + "ip": "159.100.196.217", | ||
| 322 | + "name": "全球通迈阿密" | ||
| 323 | + }, | ||
| 324 | + { | ||
| 325 | + "ip": "185.114.77.84", | ||
| 326 | + "name": "全球通圣何塞" | ||
| 327 | + }, | ||
| 328 | + { | ||
| 329 | + "ip": "159.100.195.230", | ||
| 330 | + "name": "全球通洛杉矶" | ||
| 331 | + }, | ||
| 332 | + { | ||
| 333 | + "ip": "bjms1.3mang.com", | ||
| 334 | + "name": "全球通" | ||
| 335 | + }, | ||
| 336 | + { | ||
| 337 | + "ip": "159.100.192.188", | ||
| 338 | + "name": "全球通芝加哥" | ||
| 339 | + } | ||
| 340 | + ], | ||
| 341 | + "加拿大": [ | ||
| 342 | + { | ||
| 343 | + "ip": "38.83.109.142", | ||
| 344 | + "name": "达拉斯" | ||
| 345 | + }, | ||
| 346 | + { | ||
| 347 | + "ip": "45.126.244.41", | ||
| 348 | + "name": "全球通达拉斯" | ||
| 349 | + }, | ||
| 350 | + { | ||
| 351 | + "ip": "185.114.76.243", | ||
| 352 | + "name": "全球通阿什本" | ||
| 353 | + }, | ||
| 354 | + { | ||
| 355 | + "ip": "159.100.196.217", | ||
| 356 | + "name": "全球通迈阿密" | ||
| 357 | + }, | ||
| 358 | + { | ||
| 359 | + "ip": "185.114.77.84", | ||
| 360 | + "name": "全球通圣何塞" | ||
| 361 | + }, | ||
| 362 | + { | ||
| 363 | + "ip": "159.100.195.230", | ||
| 364 | + "name": "全球通洛杉矶" | ||
| 365 | + }, | ||
| 366 | + { | ||
| 367 | + "ip": "bjms1.3mang.com", | ||
| 368 | + "name": "全球通" | ||
| 369 | + }, | ||
| 370 | + { | ||
| 371 | + "ip": "159.100.192.188", | ||
| 372 | + "name": "全球通芝加哥" | ||
| 373 | + } | ||
| 374 | + ], | ||
| 375 | + "墨西哥": [ | ||
| 376 | + { | ||
| 377 | + "ip": "38.83.109.142", | ||
| 378 | + "name": "达拉斯" | ||
| 379 | + }, | ||
| 380 | + { | ||
| 381 | + "ip": "45.126.244.41", | ||
| 382 | + "name": "全球通达拉斯" | ||
| 383 | + }, | ||
| 384 | + { | ||
| 385 | + "ip": "185.114.76.243", | ||
| 386 | + "name": "全球通阿什本" | ||
| 387 | + }, | ||
| 388 | + { | ||
| 389 | + "ip": "159.100.196.217", | ||
| 390 | + "name": "全球通迈阿密" | ||
| 391 | + }, | ||
| 392 | + { | ||
| 393 | + "ip": "185.114.77.84", | ||
| 394 | + "name": "全球通圣何塞" | ||
| 395 | + }, | ||
| 396 | + { | ||
| 397 | + "ip": "159.100.195.230", | ||
| 398 | + "name": "全球通洛杉矶" | ||
| 399 | + }, | ||
| 400 | + { | ||
| 401 | + "ip": "bjms1.3mang.com", | ||
| 402 | + "name": "全球通" | ||
| 403 | + }, | ||
| 404 | + { | ||
| 405 | + "ip": "159.100.192.188", | ||
| 406 | + "name": "全球通芝加哥" | ||
| 407 | + } | ||
| 408 | + ], | ||
| 409 | + "菲律宾": [ | ||
| 410 | + { | ||
| 411 | + "ip": "223.255.248.122", | ||
| 412 | + "name": "香港" | ||
| 413 | + }, | ||
| 414 | + { | ||
| 415 | + "ip": "118.193.20.130", | ||
| 416 | + "name": "日本" | ||
| 417 | + }, | ||
| 418 | + { | ||
| 419 | + "ip": "118.193.24.38", | ||
| 420 | + "name": "新加坡" | ||
| 421 | + }, | ||
| 422 | + { | ||
| 423 | + "ip": "bjms1.3mang.com", | ||
| 424 | + "name": "全球通" | ||
| 425 | + }, | ||
| 426 | + { | ||
| 427 | + "ip": "159.100.194.120", | ||
| 428 | + "name": "全球通日本" | ||
| 429 | + }, | ||
| 430 | + { | ||
| 431 | + "ip": "185.114.78.179", | ||
| 432 | + "name": "全球通新加坡" | ||
| 433 | + }, | ||
| 434 | + { | ||
| 435 | + "ip": "159.100.205.129", | ||
| 436 | + "name": "全球通台湾" | ||
| 437 | + }, | ||
| 438 | + { | ||
| 439 | + "ip": "192.158.245.185", | ||
| 440 | + "name": "全球通韩国" | ||
| 441 | + }, | ||
| 442 | + { | ||
| 443 | + "ip": "103.29.35.63", | ||
| 444 | + "name": "全球通印度" | ||
| 445 | + }, | ||
| 446 | + { | ||
| 447 | + "ip": "199.59.231.234", | ||
| 448 | + "name": "全球通香港" | ||
| 449 | + } | ||
| 450 | + ], | ||
| 451 | + "越南": [ | ||
| 452 | + { | ||
| 453 | + "ip": "223.255.248.122", | ||
| 454 | + "name": "香港" | ||
| 455 | + }, | ||
| 456 | + { | ||
| 457 | + "ip": "118.193.20.130", | ||
| 458 | + "name": "日本" | ||
| 459 | + }, | ||
| 460 | + { | ||
| 461 | + "ip": "118.193.24.38", | ||
| 462 | + "name": "新加坡" | ||
| 463 | + }, | ||
| 464 | + { | ||
| 465 | + "ip": "bjms1.3mang.com", | ||
| 466 | + "name": "全球通" | ||
| 467 | + }, | ||
| 468 | + { | ||
| 469 | + "ip": "159.100.194.120", | ||
| 470 | + "name": "全球通日本" | ||
| 471 | + }, | ||
| 472 | + { | ||
| 473 | + "ip": "185.114.78.179", | ||
| 474 | + "name": "全球通新加坡" | ||
| 475 | + }, | ||
| 476 | + { | ||
| 477 | + "ip": "159.100.205.129", | ||
| 478 | + "name": "全球通台湾" | ||
| 479 | + }, | ||
| 480 | + { | ||
| 481 | + "ip": "192.158.245.185", | ||
| 482 | + "name": "全球通韩国" | ||
| 483 | + }, | ||
| 484 | + { | ||
| 485 | + "ip": "103.29.35.63", | ||
| 486 | + "name": "全球通印度" | ||
| 487 | + }, | ||
| 488 | + { | ||
| 489 | + "ip": "199.59.231.234", | ||
| 490 | + "name": "全球通香港" | ||
| 491 | + } | ||
| 492 | + ], | ||
| 493 | + "泰国": [ | ||
| 494 | + { | ||
| 495 | + "ip": "223.255.248.122", | ||
| 496 | + "name": "香港" | ||
| 497 | + }, | ||
| 498 | + { | ||
| 499 | + "ip": "118.193.20.130", | ||
| 500 | + "name": "日本" | ||
| 501 | + }, | ||
| 502 | + { | ||
| 503 | + "ip": "118.193.24.38", | ||
| 504 | + "name": "新加坡" | ||
| 505 | + }, | ||
| 506 | + { | ||
| 507 | + "ip": "bjms1.3mang.com", | ||
| 508 | + "name": "全球通" | ||
| 509 | + }, | ||
| 510 | + { | ||
| 511 | + "ip": "159.100.194.120", | ||
| 512 | + "name": "全球通日本" | ||
| 513 | + }, | ||
| 514 | + { | ||
| 515 | + "ip": "185.114.78.179", | ||
| 516 | + "name": "全球通新加坡" | ||
| 517 | + }, | ||
| 518 | + { | ||
| 519 | + "ip": "159.100.205.129", | ||
| 520 | + "name": "全球通台湾" | ||
| 521 | + }, | ||
| 522 | + { | ||
| 523 | + "ip": "192.158.245.185", | ||
| 524 | + "name": "全球通韩国" | ||
| 525 | + }, | ||
| 526 | + { | ||
| 527 | + "ip": "103.29.35.63", | ||
| 528 | + "name": "全球通印度" | ||
| 529 | + }, | ||
| 530 | + { | ||
| 531 | + "ip": "199.59.231.234", | ||
| 532 | + "name": "全球通香港" | ||
| 533 | + } | ||
| 534 | + ], | ||
| 535 | + "default": [ | ||
| 536 | + { | ||
| 537 | + "ip": "bjms1.3mang.com", | ||
| 538 | + "name": "全球通" | ||
| 539 | + }, | ||
| 540 | + { | ||
| 541 | + "ip": "qims.3mang.com", | ||
| 542 | + "name": "全球通-备" | ||
| 543 | + }, | ||
| 544 | + { | ||
| 545 | + "ip": "38.83.109.142", | ||
| 546 | + "name": "达拉斯" | ||
| 547 | + }, | ||
| 548 | + { | ||
| 549 | + "ip": "118.193.20.130", | ||
| 550 | + "name": "日本" | ||
| 551 | + }, | ||
| 552 | + { | ||
| 553 | + "ip": "38.123.107.18", | ||
| 554 | + "name": "德国" | ||
| 555 | + }, | ||
| 556 | + { | ||
| 557 | + "ip": "223.255.248.122", | ||
| 558 | + "name": "香港" | ||
| 559 | + }, | ||
| 560 | + { | ||
| 561 | + "ip": "148.153.8.22", | ||
| 562 | + "port": "1935", | ||
| 563 | + "name": "纽约" | ||
| 564 | + }, | ||
| 565 | + { | ||
| 566 | + "ip": "38.121.61.242", | ||
| 567 | + "port": "1935", | ||
| 568 | + "name": "洛杉矶" | ||
| 569 | + }, | ||
| 570 | + { | ||
| 571 | + "ip": "118.193.24.38", | ||
| 572 | + "name": "新加坡" | ||
| 573 | + }, | ||
| 574 | + { | ||
| 575 | + "ip": "159.100.194.120", | ||
| 576 | + "name": "全球通日本" | ||
| 577 | + }, | ||
| 578 | + { | ||
| 579 | + "ip": "159.100.192.188", | ||
| 580 | + "name": "全球通芝加哥" | ||
| 581 | + }, | ||
| 582 | + { | ||
| 583 | + "ip": "45.126.244.41", | ||
| 584 | + "name": "全球通达拉斯" | ||
| 585 | + }, | ||
| 586 | + { | ||
| 587 | + "ip": "45.126.246.148", | ||
| 588 | + "name": "全球通德国" | ||
| 589 | + }, | ||
| 590 | + { | ||
| 591 | + "ip": "192.158.245.185", | ||
| 592 | + "name": "全球通韩国" | ||
| 593 | + }, | ||
| 594 | + { | ||
| 595 | + "ip": "103.29.35.63", | ||
| 596 | + "name": "全球通印度" | ||
| 597 | + }, | ||
| 598 | + { | ||
| 599 | + "ip": "202.127.74.126", | ||
| 600 | + "name": "全球通新加坡" | ||
| 601 | + }, | ||
| 602 | + { | ||
| 603 | + "ip": "199.59.231.234", | ||
| 604 | + "name": "全球通香港" | ||
| 605 | + }, | ||
| 606 | + { | ||
| 607 | + "ip": "159.100.205.129", | ||
| 608 | + "name": "全球通台湾" | ||
| 609 | + } | ||
| 610 | + ] | ||
| 611 | + }, | ||
| 612 | + "MCU":{ | ||
| 613 | + "default": [ | ||
| 614 | + { | ||
| 615 | + "ip": "123.56.73.119", | ||
| 616 | + "port": "1260", | ||
| 617 | + "name": "" | ||
| 618 | + }, | ||
| 619 | + { | ||
| 620 | + "ip": "123.56.73.119", | ||
| 621 | + "port": "1270", | ||
| 622 | + "name": "" | ||
| 623 | + }, | ||
| 624 | + { | ||
| 625 | + "ip": "123.56.69.230", | ||
| 626 | + "port": "1260", | ||
| 627 | + "name": "" | ||
| 628 | + }, | ||
| 629 | + { | ||
| 630 | + "ip": "123.56.69.230", | ||
| 631 | + "port": "1270", | ||
| 632 | + "name": "" | ||
| 633 | + } | ||
| 634 | + ] | ||
| 635 | + } | ||
| 636 | + | ||
| 637 | + }*/ | ||
| 638 | + } | ||
| 639 | +} | ||
| 640 | + | ||
| 641 | +ServerConfig.sassServerJson={ | ||
| 642 | + "MS":{}, | ||
| 643 | + "MCU":{} | ||
| 644 | +}; | ||
| 645 | +ServerConfig.localServerJson={ | ||
| 646 | + "MS":{}, | ||
| 647 | + "MCU":{} | ||
| 648 | +}; | ||
| 649 | +ServerConfig.serverListData={ | ||
| 650 | + "MS":{}, | ||
| 651 | + "MCU":{} | ||
| 652 | +}; | ||
| 653 | +export default ServerConfig; |
| @@ -206,6 +206,9 @@ class MCU extends Emiter { | @@ -206,6 +206,9 @@ class MCU extends Emiter { | ||
| 206 | // 主动建立MCU连接 | 206 | // 主动建立MCU连接 |
| 207 | joinMCU(_classInfo) { | 207 | joinMCU(_classInfo) { |
| 208 | loger.log('开始建立EverSocket通道.'); | 208 | loger.log('开始建立EverSocket通道.'); |
| 209 | + if(!this.classInfo||!this.classInfo.MCUServerIP){ | ||
| 210 | + loger.error('建立MCU连接->地址无效.'); | ||
| 211 | + } | ||
| 209 | GlobalConfig.classJoinSuccess = false; | 212 | GlobalConfig.classJoinSuccess = false; |
| 210 | loger.log(_classInfo); | 213 | loger.log(_classInfo); |
| 211 | _classInfo.classId = parseInt(_classInfo.classId); // classId 必须整形 | 214 | _classInfo.classId = parseInt(_classInfo.classId); // classId 必须整形 |
-
请 注册 或 登录 后发表评论