gemercheung 3 gadi atpakaļ
vecāks
revīzija
9e7bc50db1
1 mainītis faili ar 8 papildinājumiem un 4 dzēšanām
  1. 8 4
      src/scene/scene.service.ts

+ 8 - 4
src/scene/scene.service.ts

@@ -34,6 +34,7 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
   public _rotateTimeout: NodeJS.Timeout;
   public _moveTimeout: NodeJS.Timeout;
   public _JoyStickingSteamTimeout: NodeJS.Timeout;
+  public _packFrameTimeout: NodeJS.Timeout;
   public startSteaming = new BehaviorSubject<boolean>(false);
   public onRotating = new BehaviorSubject<boolean>(false);
   public onMoving = new BehaviorSubject<boolean>(false);
@@ -647,6 +648,8 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
       this.logger.log('walking-path', path);
       if (!path) {
         console.log('不存在--path', path);
+        this.cleanMoveSteam();
+        this.clearWalkingJoints();
         this.resumeStream();
         return;
       }
@@ -1123,25 +1126,26 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
 
   async handleIframeRequest() {
     //TODO Iframe 最终传什么?
+    this.holdSteam();
     this.requestIFrameQueue.next(this.streamService.lastStreamFrame.getValue());
-
     if (!this.requestIFrameQueueSub) {
       this.requestIFrameQueueSub = this.requestIFrameQueue.subscribe(
         async (frameData: StreamFrameType) => {
           if (frameData) {
-
             const nextFrame = this.frameCnt.getValue() + 1;
             this.logger.warn('lostIframe', nextFrame);
             frameData.frame = nextFrame;
             frameData.DIR = 1;
-
             const res = await this.streamService.pushFrameToSteam(frameData);
             if (res.done) {
               this.logger.error(
                 ' frame:' + res.frame + '  补帧::' + JSON.stringify(frameData),
               );
               this.frameCnt.next(res.frame);
-              this.resumeStream();
+              clearTimeout(this._packFrameTimeout);
+              this._packFrameTimeout = setTimeout(() => {
+                this.resumeStream();
+              }, 100);
             } else {
               console.error('补帧有误:', JSON.stringify(frameData));
             }