Commit f7edf172455c9c84b8160444a1943995572d6596

Authored by Min
1 parent 69c049be

1.app心跳包 定时去检查当前WebSocket连接状态,如果是打开状态,则先发送消息;如果websoket关闭了,则重新建立连接

src/components/Common/PersonCenter/PersonCenterAddFace.js
@@ -10,7 +10,6 @@ const PersonCenterAddFace = Form.create({ @@ -10,7 +10,6 @@ const PersonCenterAddFace = Form.create({
10 mapPropsToFields(props) {}, 10 mapPropsToFields(props) {},
11 })(props => { 11 })(props => {
12 const { onCancel, handleModalClose, addFaceVisible } = props; 12 const { onCancel, handleModalClose, addFaceVisible } = props;
13 - console.log('sssaddFaceVisibles', addFaceVisible);  
14 const GetFace = commonFunc.showMessage(props.app.commonConst, "GetFace"); /* 在线用户 */ 13 const GetFace = commonFunc.showMessage(props.app.commonConst, "GetFace"); /* 在线用户 */
15 return ( 14 return (
16 <div> 15 <div>
src/components/Common/ProblemFeedback/ProblemFeedback.js
@@ -250,7 +250,7 @@ const ProblemFeedback = props =&gt; { @@ -250,7 +250,7 @@ const ProblemFeedback = props =&gt; {
250 socketRef.current === null 250 socketRef.current === null
251 ) { 251 ) {
252 if (useDefaultWs.current) { 252 if (useDefaultWs.current) {
253 - console.log("=====检测到是小羚羊项目管理系统,不打开新的websocket。"); 253 + // console.log("=====检测到是小羚羊项目管理系统,不打开新的websocket。");
254 } else { 254 } else {
255 const { app } = props; 255 const { app } = props;
256 const { userinfo } = app; 256 const { userinfo } = app;
src/models/app.js
@@ -604,10 +604,17 @@ export default { @@ -604,10 +604,17 @@ export default {
604 // 3s内没返回消息,则重新创建ws,重新发送 604 // 3s内没返回消息,则重新创建ws,重新发送
605 clearTimeout(window.wsTimer); 605 clearTimeout(window.wsTimer);
606 window.wsTimer = setTimeout(() => { 606 window.wsTimer = setTimeout(() => {
607 - console.log('================超时未收到WebSocket消息,重新创建ws并发送信息======================');  
608 - window.wsHistoryArgs = args;  
609 - ws.onmessageTmp && (window.onmessageTmp = ws.onmessageTmp);  
610 - dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } }); 607 + // 检查当前WebSocket连接状态
  608 + if (ws && ws.readyState === WebSocket.OPEN) {
  609 + console.log('================WebSocket连接正常但超时未收到消息,重新发送信息======================');
  610 + // 先尝试重新发送消息,而不是直接创建新连接
  611 + ws.originalSend.apply(ws, args);
  612 + } else {
  613 + console.log('================超时未收到WebSocket消息,重新创建ws并发送信息======================');
  614 + window.wsHistoryArgs = args;
  615 + ws.onmessageTmp && (window.onmessageTmp = ws.onmessageTmp);
  616 + dispatch({ type: 'app/createWebSocket', payload: { reStart: true, dispatch } });
  617 + }
611 }, 3000); 618 }, 3000);
612 } 619 }
613 ws.originalSend.apply(ws, args); 620 ws.originalSend.apply(ws, args);
@@ -650,8 +657,8 @@ export default { @@ -650,8 +657,8 @@ export default {
650 const msgPopupData = utils.isNotEmptyArr(msgObj.popup) ? msgObj.popup : []; 657 const msgPopupData = utils.isNotEmptyArr(msgObj.popup) ? msgObj.popup : [];
651 const msgHeadData = utils.isNotEmptyObject(msgObj.data) ? msgObj.data : []; 658 const msgHeadData = utils.isNotEmptyObject(msgObj.data) ? msgObj.data : [];
652 // 检查是否在 CommonBill 相关页面 659 // 检查是否在 CommonBill 相关页面
653 - const isCommonBillPage = location.pathname.indexOf("/indexPage/commonBill") > -1 ||  
654 - location.pathname.indexOf("/indexPage/commonCheckBill") > -1 || 660 + const isCommonBillPage = location.pathname.indexOf("/indexPage/commonBill") > -1 ||
  661 + location.pathname.indexOf("/indexPage/commonCheckBill") > -1 ||
655 location.pathname.indexOf("/indexPage/commonBillDeliver") > -1 || 662 location.pathname.indexOf("/indexPage/commonBillDeliver") > -1 ||
656 location.pathname.indexOf("/indexPage/commonNewBill") > -1 || 663 location.pathname.indexOf("/indexPage/commonNewBill") > -1 ||
657 location.pathname.indexOf("/indexPage/commonSubBill") > -1 || 664 location.pathname.indexOf("/indexPage/commonSubBill") > -1 ||