李勇

1.https和http情况下分别处理MCU SAAS DOC的80端口处理;

@@ -58,7 +58,7 @@ export default class MessageEntrance extends Emiter { @@ -58,7 +58,7 @@ export default class MessageEntrance extends Emiter {
58 constructor() { 58 constructor() {
59 super(); 59 super();
60 //sdk 信息 60 //sdk 信息
61 - GlobalConfig.sdkVersion = "v1.71.0.20170813"; 61 + GlobalConfig.sdkVersion = "v1.73.1.20170814";
62 loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); 62 loger.warn("sdkVersion:" + GlobalConfig.sdkVersion);
63 63
64 //设置 64 //设置
@@ -504,7 +504,7 @@ export default class MessageEntrance extends Emiter { @@ -504,7 +504,7 @@ export default class MessageEntrance extends Emiter {
504 GlobalConfig.portal = _param.portal||""; 504 GlobalConfig.portal = _param.portal||"";
505 if(GlobalConfig.isHttps==true){ 505 if(GlobalConfig.isHttps==true){
506 //https的时候替换所有80端口 506 //https的时候替换所有80端口
507 - GlobalConfig.portal= GlobalConfig.portal.replace(":80",""); 507 + GlobalConfig.portal= GlobalConfig.replacePort(GlobalConfig.portal,":80","");
508 } 508 }
509 509
510 GlobalConfig.userId = _param.userId || "0"; 510 GlobalConfig.userId = _param.userId || "0";
@@ -1091,7 +1091,7 @@ export default class MessageEntrance extends Emiter { @@ -1091,7 +1091,7 @@ export default class MessageEntrance extends Emiter {
1091 LogManager.userId = GlobalConfig.userId;//userId 1091 LogManager.userId = GlobalConfig.userId;//userId
1092 LogManager.nodeId = GlobalConfig.nodeId;//nodeId 1092 LogManager.nodeId = GlobalConfig.nodeId;//nodeId
1093 LogManager.userName = GlobalConfig.userName;//用户名称 1093 LogManager.userName = GlobalConfig.userName;//用户名称
1094 - LogManager.logUrl = GlobalConfig.logUrl;//日志服务器地址 //http://log.3mang.com:8888 1094 + LogManager.logUrl = GlobalConfig.logUrl;//日志服务器地址 //http://log.3mang.com
1095 1095
1096 loger.log('加入课堂成功->'); 1096 loger.log('加入课堂成功->');
1097 loger.log(joinClassSuccessCallBackData); 1097 loger.log(joinClassSuccessCallBackData);
@@ -1524,6 +1524,10 @@ export default class MessageEntrance extends Emiter { @@ -1524,6 +1524,10 @@ export default class MessageEntrance extends Emiter {
1524 //是否自动开始(身份是host的时候才用到的) 1524 //是否自动开始(身份是host的时候才用到的)
1525 GlobalConfig.isAutoStartClass = _data.autoRecord || 0; 1525 GlobalConfig.isAutoStartClass = _data.autoRecord || 0;
1526 GlobalConfig.logUrl = _data.logUrl || ""; 1526 GlobalConfig.logUrl = _data.logUrl || "";
  1527 + GlobalConfig.logUrl=GlobalConfig.logUrl.replace("https://","");
  1528 + GlobalConfig.logUrl=GlobalConfig.logUrl.replace("http://","");
  1529 + GlobalConfig.logUrl=GlobalConfig.locationProtocol+GlobalConfig.logUrl;
  1530 +
1527 GlobalConfig.serverTime = _data.serverTime || new Date().getTime(); //获取服务器时间戳 1531 GlobalConfig.serverTime = _data.serverTime || new Date().getTime(); //获取服务器时间戳
1528 GlobalConfig.serverAndLoacTimeDistanc = (new Date().getTime() - GlobalConfig.serverTime) / 1000; //当前系统时间和服务器时间的差值 (秒) 1532 GlobalConfig.serverAndLoacTimeDistanc = (new Date().getTime() - GlobalConfig.serverTime) / 1000; //当前系统时间和服务器时间的差值 (秒)
1529 loger.warn("服务器时间:" + GlobalConfig.serverTime + " 系统时间:" + new Date().getTime() + " 时间差:" + GlobalConfig.serverAndLoacTimeDistanc); 1533 loger.warn("服务器时间:" + GlobalConfig.serverTime + " 系统时间:" + new Date().getTime() + " 时间差:" + GlobalConfig.serverAndLoacTimeDistanc);
@@ -1544,6 +1548,11 @@ export default class MessageEntrance extends Emiter { @@ -1544,6 +1548,11 @@ export default class MessageEntrance extends Emiter {
1544 GlobalConfig.DOCServerIP = GlobalConfig.docList[index].ip || ""; 1548 GlobalConfig.DOCServerIP = GlobalConfig.docList[index].ip || "";
1545 GlobalConfig.DOCServerPort = GlobalConfig.docList[index].port || ""; 1549 GlobalConfig.DOCServerPort = GlobalConfig.docList[index].port || "";
1546 1550
  1551 + if(GlobalConfig.isHttps){
  1552 + //https的时候替换所有80端口
  1553 + GlobalConfig.DOCServerPort= GlobalConfig.replacePort(GlobalConfig.DOCServerPort,"80","");
  1554 + }
  1555 +
1547 } 1556 }
1548 //录制回放文件的下载地址 1557 //录制回放文件的下载地址
1549 if (GlobalConfig.recordList && GlobalConfig.recordList.length > 0) { 1558 if (GlobalConfig.recordList && GlobalConfig.recordList.length > 0) {
@@ -2292,7 +2301,7 @@ export default class MessageEntrance extends Emiter { @@ -2292,7 +2301,7 @@ export default class MessageEntrance extends Emiter {
2292 GlobalConfig.portal = _param.portal||""; 2301 GlobalConfig.portal = _param.portal||"";
2293 if(GlobalConfig.isHttps==true){ 2302 if(GlobalConfig.isHttps==true){
2294 //https的时候替换所有80端口 2303 //https的时候替换所有80端口
2295 - GlobalConfig.portal= GlobalConfig.portal.replace(":80",""); 2304 + GlobalConfig.portal= GlobalConfig.replacePort(GlobalConfig.portal,":80","");
2296 } 2305 }
2297 2306
2298 GlobalConfig.userRole = ApeConsts.normal; //*************很重要,录制回放的时候,身份模式是普通人******** 2307 GlobalConfig.userRole = ApeConsts.normal; //*************很重要,录制回放的时候,身份模式是普通人********
@@ -36,7 +36,12 @@ class EverSocket extends Emiter { @@ -36,7 +36,12 @@ class EverSocket extends Emiter {
36 } 36 }
37 this._enableEverSocket = true; 37 this._enableEverSocket = true;
38 //this.wsURL = 'ws://' + ip + ':' + port; 38 //this.wsURL = 'ws://' + ip + ':' + port;
  39 + if(port){
39 this.wsURL = GlobalConfig.websocketProtocol + ip + ':' + port; 40 this.wsURL = GlobalConfig.websocketProtocol + ip + ':' + port;
  41 + }else {
  42 + this.wsURL = GlobalConfig.websocketProtocol + ip;
  43 + }
  44 +
40 this._newConnection(); 45 this._newConnection();
41 } 46 }
42 47
@@ -81,6 +86,10 @@ class EverSocket extends Emiter { @@ -81,6 +86,10 @@ class EverSocket extends Emiter {
81 } 86 }
82 87
83 _newConnection() { 88 _newConnection() {
  89 + if(GlobalConfig.isHttps==true){
  90 + //https的时候替换所有80端口
  91 + this.wsURL= GlobalConfig.replacePort(this.wsURL,":80","");
  92 + }
84 this.websocket = new WebSocket(this.wsURL); 93 this.websocket = new WebSocket(this.wsURL);
85 this.websocket.binaryType = 'arraybuffer'; 94 this.websocket.binaryType = 'arraybuffer';
86 this.websocket.onopen = this._onOpen.bind(this); 95 this.websocket.onopen = this._onOpen.bind(this);
@@ -335,6 +335,27 @@ class GlobalConfig { @@ -335,6 +335,27 @@ class GlobalConfig {
335 } 335 }
336 loger.log("videoCDNAddrList->", this.videoCDNAddrList); 336 loger.log("videoCDNAddrList->", this.videoCDNAddrList);
337 } 337 }
  338 +
  339 + //把IP中的端口换成指定端口
  340 + static replacePort(_ipport,_curPort,_newPort){
  341 + loger.warn("替换端口->",_ipport,_curPort,_newPort);
  342 + if(!_ipport||!_curPort){
  343 + //数据不正确,直接返回原数据
  344 + return _ipport;
  345 + }
  346 + try {
  347 + //判断要替换的端口是否在最后的位置,否则是不能替换的,比如替换":80"端口,如果地址是"xxx.xxx.xxx:8080" 不判断的话就会出错
  348 + let lastIndex=_ipport.lastIndexOf(_curPort);
  349 + if((_ipport.length-_curPort.length)==lastIndex){
  350 + let ipportNew=_ipport.replace(_curPort,_newPort);
  351 + return ipportNew
  352 + }
  353 + return _ipport;
  354 + }catch (err){
  355 + return _ipport;
  356 + }
  357 +
  358 + }
338 } 359 }
339 360
340 GlobalConfig.statusCode_0 = { "code": 0, message: "SDK 未初始化" }; 361 GlobalConfig.statusCode_0 = { "code": 0, message: "SDK 未初始化" };
@@ -15,7 +15,7 @@ const loger = Loger.getLoger('IpManager'); @@ -15,7 +15,7 @@ const loger = Loger.getLoger('IpManager');
15 15
16 const TIME_OUT = 2000;//选点超时 16 const TIME_OUT = 2000;//选点超时
17 const MS_DEFAULT_PORT = "1935";//默认流媒体端口 17 const MS_DEFAULT_PORT = "1935";//默认流媒体端口
18 -const MCU_DEFAULT_PORT = "7777";//默认的mcu端口 18 +const MCU_DEFAULT_PORT = "";//默认的mcu端口 //7777
19 const SPEED_TEST_PORT = '5555';//测速端口(MCU/MS) 19 const SPEED_TEST_PORT = '5555';//测速端口(MCU/MS)
20 20
21 class IpManager extends Emiter { 21 class IpManager extends Emiter {