Browse Source

需折减到 mtp_v6分支:行情重连后重新发起心跳

huangbin 4 years ago
parent
commit
77b48ff5c0

+ 0 - 1
src/services/bus/token.ts

@@ -23,7 +23,6 @@ export function getToken(): string {
  * 处理token校验
  */
 export function handleTokenCheck() {
-    console.log('校验token中==========')
     return tokenCheck().catch((err) => {
         Router.push({ path: '/login' }); // 回到登录页面
         console.error(`token校验失败:${err}`);

+ 4 - 0
src/services/index.ts

@@ -184,6 +184,8 @@ export default new (class LifeCycleCtr {
 
     /** 处理交易相关信息 */
     tradingRelevant(socket: MTP2WebSocket<Package50>) {
+        // eslint-disable-next-line @typescript-eslint/no-this-alias
+        const _this = this
         // 推送信息
         socket.onReceivePush = (_self, msg) => {
             switch (msg.funCode) {
@@ -227,6 +229,8 @@ export default new (class LifeCycleCtr {
                     break;
                 /** 重连成功,将进行业务操作 */
                 case ReconnectChangeState.ReconnectSuccessed:
+                    //重新发起心跳
+                    _this.startBeatTime('trade');
                     // 重新启动定时 token 校验
                     checkTokenAction()
                     console.log(obj.host, '重连成功,将进行业务操作');

+ 3 - 0
src/services/socket/login/index.ts

@@ -77,6 +77,7 @@ export const tokenCheck = (): Promise<string> => {
                 onSuccess: (res) => {
                     const { isSuccess, result } = parseProtoRsp50(res, 'TokenCheckRsp');
                     if (isSuccess) {
+                        console.log('token 校验成功::::::')
                         const systemTime = Number(result.SystemTime);
                         const time = moment(new Date(systemTime)).format('YYYY-MM-DD HH:mm:ss');
                         APP.set('systemDate', time);
@@ -84,10 +85,12 @@ export const tokenCheck = (): Promise<string> => {
                         resolve('ok');
                     } else {
                         reject(result);
+                        console.log(`token 校验成功:${result}`)
                     }
                 },
                 onFail: (err) => {
                     reject(err);
+                    console.log(`token 校验成功:${err}`)
                 },
             } as Callback);
         } else {

+ 0 - 1
src/utils/websocket/index.ts

@@ -219,7 +219,6 @@ export class MTP2WebSocket<T extends Package40 | Package50> {
      */
     send(p: T, rsp?: number, callback?: Callback) {
         if (this.connState != 2) {
-            debugger
             if (callback && callback.onFail) callback.onFail(new Error('连接状态错误'));
             return;
         }