Commit f7edf172455c9c84b8160444a1943995572d6596
1 parent
69c049be
1.app心跳包 定时去检查当前WebSocket连接状态,如果是打开状态,则先发送消息;如果websoket关闭了,则重新建立连接
Showing
3 changed files
with
14 additions
and
8 deletions
src/components/Common/PersonCenter/PersonCenterAddFace.js
| ... | ... | @@ -10,7 +10,6 @@ const PersonCenterAddFace = Form.create({ |
| 10 | 10 | mapPropsToFields(props) {}, |
| 11 | 11 | })(props => { |
| 12 | 12 | const { onCancel, handleModalClose, addFaceVisible } = props; |
| 13 | - console.log('sssaddFaceVisibles', addFaceVisible); | |
| 14 | 13 | const GetFace = commonFunc.showMessage(props.app.commonConst, "GetFace"); /* 在线用户 */ |
| 15 | 14 | return ( |
| 16 | 15 | <div> | ... | ... |
src/components/Common/ProblemFeedback/ProblemFeedback.js
| ... | ... | @@ -250,7 +250,7 @@ const ProblemFeedback = props => { |
| 250 | 250 | socketRef.current === null |
| 251 | 251 | ) { |
| 252 | 252 | if (useDefaultWs.current) { |
| 253 | - console.log("=====检测到是小羚羊项目管理系统,不打开新的websocket。"); | |
| 253 | + // console.log("=====检测到是小羚羊项目管理系统,不打开新的websocket。"); | |
| 254 | 254 | } else { |
| 255 | 255 | const { app } = props; |
| 256 | 256 | const { userinfo } = app; | ... | ... |
src/models/app.js
| ... | ... | @@ -604,10 +604,17 @@ export default { |
| 604 | 604 | // 3s内没返回消息,则重新创建ws,重新发送 |
| 605 | 605 | clearTimeout(window.wsTimer); |
| 606 | 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 | 618 | }, 3000); |
| 612 | 619 | } |
| 613 | 620 | ws.originalSend.apply(ws, args); |
| ... | ... | @@ -650,8 +657,8 @@ export default { |
| 650 | 657 | const msgPopupData = utils.isNotEmptyArr(msgObj.popup) ? msgObj.popup : []; |
| 651 | 658 | const msgHeadData = utils.isNotEmptyObject(msgObj.data) ? msgObj.data : []; |
| 652 | 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 | 662 | location.pathname.indexOf("/indexPage/commonBillDeliver") > -1 || |
| 656 | 663 | location.pathname.indexOf("/indexPage/commonNewBill") > -1 || |
| 657 | 664 | location.pathname.indexOf("/indexPage/commonSubBill") > -1 || | ... | ... |