Преглед на файлове

增加用户退出清除

gemercheung преди 3 години
родител
ревизия
7543117b97
променени са 2 файла, в които са добавени 20 реда и са изтрити 13 реда
  1. 12 1
      src/rotate/rotate.service.ts
  2. 8 12
      src/scene/scene.service.ts

+ 12 - 1
src/rotate/rotate.service.ts

@@ -26,7 +26,7 @@ export class RotateService {
   constructor(
     private cacheService: CacheService, // private sceneService: SceneService,
     private configService: ConfigService,
-  ) {}
+  ) { }
   private actionRequestPool = {};
   private logger: Logger = new Logger('rotateService');
   private Actions = {
@@ -164,6 +164,17 @@ export class RotateService {
     return reply;
   }
 
+  /**
+   * delete User object
+   * @param userId
+   */
+  deleteUser(userId: string) {
+    if (userId in this.users) {
+      delete this.users[userId];
+      console.log('[delete User]--存在用户 %s', userId);
+    }
+  }
+
   // 顺序旋转请求
   seqExeRotate = seqExeAsyncFn(this.rotate);
 

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

@@ -232,13 +232,9 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     }
   }
 
-  exit(request: ExitRequest) {
+  exit() {
     this.frameCnt.next(-1);
-    this.stopStream();
-    // const exitReply = this.sceneGrpcService.exit(request);
-    // exitReply.subscribe((reply) => {
-    //   console.log('exitReply', reply);
-    // });
+    this.rotateService.deleteUser(this.user_id);
   }
 
   async rotate(request: RotateRequest) {
@@ -739,12 +735,12 @@ export class SceneService implements OnModuleInit, OnModuleDestroy {
     this.stopStream();
     this.startSteaming.next(false);
     this.streamService.closeChannel();
-    const exitRequest: ExitRequest = {
-      action_type: 1002,
-      user_id: this.user_id,
-      trace_id: '',
-    };
-    this.exit(exitRequest);
+    // const exitRequest: ExitRequest = {
+    //   action_type: 1002,
+    //   user_id: this.user_id,
+    //   trace_id: '',
+    // };
+    this.exit();
   }
 
   handleMessage(message: string | Buffer) {