gemercheung 3 年 前
コミット
fbe981b161
1 ファイル変更17 行追加0 行削除
  1. 17 0
      src/scene/scene.service.ts

+ 17 - 0
src/scene/scene.service.ts

@@ -61,6 +61,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
   private clickQueue: RxQueue = new DebounceQueue(500);
   private moveQueue: RxQueue = new DelayQueue(10);
   private joystickQueue: RxQueue = new DebounceQueue(500);
+  private requestIFrameQueue: RxQueue = new DebounceQueue(1000);
+
+  private requestIFrameQueueSub: any;
   private rotateTimeStamp: number;
   private lastMoveCnt = -1;
 
@@ -563,6 +566,20 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
   }
 
   async handleIframeRequest() {
+    this.requestIFrameQueue.next(this.streamService.lastStreamFrame);
+    this.requestIFrameQueueSub = this.requestIFrameQueue.subscribe(
+      (frameData: StreamFrameType) => {
+        const nextFrame = this.frameCnt.getValue() + 1;
+        frameData.frame = nextFrame;
+        this.streamService.pushFrameToSteam(frameData);
+        this.frameCnt.next(nextFrame);
+        this.resumeStream();
+      },
+    );
+
+    if (!this.requestIFrameQueueSub) {
+      this.requestIFrameQueueSub.subscribe();
+    }
     //TODO Iframe 最终传什么?
     // const lastStreamFrame = this.streamService.lastStreamFrame.getValue();
     // lastStreamFrame.DIR = 1;