test pc 3 năm trước cách đây
mục cha
commit
3d41561a94
1 tập tin đã thay đổi với 16 bổ sung7 xóa
  1. 16 7
      src/scene/scene.service.ts

+ 16 - 7
src/scene/scene.service.ts

@@ -169,6 +169,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     this.onJoysticking.next(false);
     this.moveframeCnt = -1;
     this.rotateframeCnt = -1;
+    this.globalOptLock = false;
     clearInterval(this._frameInteval);
     this._frameInteval = setInterval(async () => {
       const next = this.frameCnt.getValue() + 1;
@@ -262,7 +263,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     console.log('rotateUnlock条件--->' + rotateUnlock, this.globalOptLock);
 
     if (rotateUnlock) {
-      //console.log('20220627test:handleRotate')
+      console.log('20220627test:handleRotate')
       const start = performance.now();
       // 当move时处理 _rotateCount是移动端同时触发的问题,rotateStopThrottle是减少重复抖动stop的处理。
       this.holdSteam();
@@ -821,8 +822,11 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
    * joystick 二合一推流
    * @param joystickRes StreamMetaType | StreamFrameType;
    */
+  handlePushJoyStickSteamSeq = seqExeAsyncFn(this.handlePushJoyStickSteam)
+
   async handlePushJoyStickSteam(joystickRes: StreamReplyType) {
     this.holdSteam();
+    this.globalOptLock = true
 
     //console.log('joystickRes有mediaSrc', joystickRes.mediaSrc);
     console.log(
@@ -832,9 +836,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     let streamData: StreamFrameType | StreamMetaType;
 
     // if (this.joystickFrameCnt === -1) {
-    this.joystickFrameCnt = this.frameCnt.getValue();
+    this.joystickFrameCnt = this.frameCnt.getValue() + 1;
     // }
-    this.joystickFrameCnt += 1;
+    // this.joystickFrameCnt += 1;
     const hasMedia = joystickRes?.mediaSrc && joystickRes?.mediaSrc.length > 0;
 
     if (hasMedia) {
@@ -849,6 +853,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         serverTime: this.mockserverTime,
         DIR: setDIR,
       };
+
     } else {
       streamData = {
         frame: this.joystickFrameCnt,
@@ -856,6 +861,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       };
     }
 
+    console.log('20220627test-complementFrame 进行1' + '***' + streamData.frame);
     // 过滤新东西, 推完给回false
     this.moveService.sendingFrameForJoystick = true;
 
@@ -896,16 +902,18 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
           this.user_id,
         ) as StreamReplyType;
         if (complementFrame) {
+          console.log('20220627test-complementFrame 进行' + complementFrame.mediaSrc + '***' + this.frameCnt.value);
           // 第二次或N次进入时如果有值直接重新进入流主程
-          this.handlePushJoyStickSteam(complementFrame);
+          this.handlePushJoyStickSteamSeq(complementFrame);
           this.globalOptLock = true;
         } else {
+          console.log('20220627test-complementFrame 结束');
           // 第二次或N次无pool数据再次trigger handleJoystickStop
           console.log('gemer-test-complementFrame-空2');
           this.hasJoystickFocusRepeat = false;
           this.testTimer = 0;
+          //this.handleJoystickStop(hasPush);
           this.globalOptLock = false;
-          this.handleJoystickStop(hasPush);
         }
       } else {
         this.handleJoystickStop(hasPush);
@@ -923,6 +931,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     // 最后一帧200ms
     clearTimeout(this._JoyStickingSteamTimeout);
     this._JoyStickingSteamTimeout = setTimeout(async () => {
+      console.log('20220627test-complementFrame handleJoystickStop 200ms之后');
       const complementFrame = this.moveService.complementFrame(
         this.user_id,
       ) as StreamReplyType;
@@ -934,7 +943,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         this.testTimer += 1;
         console.log('gemer-test-complementFrame-有值');
         const start = performance.now();
-        this.handlePushJoyStickSteam(complementFrame);
+        this.handlePushJoyStickSteamSeq(complementFrame);
         const stop = performance.now();
         console.log('gemer-test-handlePushJoyStickSteam', this.testTimer);
         const inMillSeconds = stop - start;
@@ -980,7 +989,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
         //     ),
         // );
         if (!this.onMoving.getValue()) {
-          this.handlePushJoyStickSteam(joystickRes);
+          this.handlePushJoyStickSteamSeq(joystickRes);
         }
       } else {
         console.log('handlejoystick:null');