gemercheung 3 years ago
parent
commit
23a9001625
3 changed files with 25 additions and 18 deletions
  1. 3 2
      config.production1.yaml
  2. 2 2
      src/get-router/get-router.service.ts
  3. 20 14
      src/move/move.service.ts

+ 3 - 2
config.production1.yaml

@@ -1,7 +1,7 @@
 app:
   prefix: /mnt/metaverse/scene
   startPoint: 29
-  appId: "0000000003"
+  appId: '0000000003'
 
 log:
   logFolder: /var/log/metaverse
@@ -35,7 +35,8 @@ redis:
 # server: ['stun:47.107.125.202:3478','stun:120.24.252.95:3478']
 #  server: ['stun:4dage:4dage168@47.107.125.202:3478','stun:120.24.252.95:3478']
 stun:
-  server: ['turn:4dage:4dage168@turn.4dage.com:4478']
+  server:
+    ['turn:4dage:4dage168@turn.4dage.com:4478', 'stun:stun.callwithus.com:3478']
   portRangeBegin: 49152
   portRangeEnd: 65535
 

+ 2 - 2
src/get-router/get-router.service.ts

@@ -27,11 +27,11 @@ export class GetRouterService implements OnModuleInit {
     // let path: string;
     if (process.env.NODE_ENV === 'development') {
       path = join(__dirname, `../ws/${app_id}/points-${app_id}.json`);
-      console.log('测试服JSON', path);
+      console.log('测试服JSON-router', path);
     }
     if (process.env.NODE_ENV === 'production') {
       path = join(`${prefix}/${app_id}/points-${app_id}.json`);
-      console.log('正式服JSON', path);
+      console.log('正式服JSON-router', path);
     }
     this.loadJSON(path);
   }

+ 20 - 14
src/move/move.service.ts

@@ -4,6 +4,7 @@ import { readFileSync } from 'fs';
 import { join } from 'path';
 import { CacheService } from 'src/cache/cache.service';
 import { RotateService } from 'src/rotate/rotate.service';
+import configuration from 'src/config/configuration';
 
 // import * as  BreakPointIds from '../../ws/points-BreakPointId.json';
 // import { SceneService } from 'src/scene/scene.service';
@@ -32,7 +33,7 @@ export class MoveService implements OnModuleInit {
     private cacheService: CacheService,
     private rotateService: RotateService,
     private configService: ConfigService,
-  ) {}
+  ) { }
   private logger: Logger = new Logger('MoveService');
   private Actions = {
     Clicking: 1,
@@ -136,17 +137,22 @@ export class MoveService implements OnModuleInit {
   // eslint-disable-next-line @typescript-eslint/no-empty-function
   async onModuleInit() {
     //const app_id = '0000000003';
-    const app_id = '0000000007';
-    const prefix = '/mnt/metaverse/scene';
+    // const app_id = '0000000007';
+    // const prefix = '/mnt/metaverse/scene';
+    const app_id = configuration().app.appId;
+    const prefix = configuration().app.prefix;
+    console.log('app_id', app_id, configuration().app.appId);
+    console.log('prefix', prefix, configuration().app.appId);
+
     let path;
     // let path: string;
     if (process.env.NODE_ENV === 'development') {
       path = join(__dirname, `../ws/${app_id}/points-${app_id}.json`);
-      console.log('测试服JSON', path);
+      console.log('测试服JSON-move', path);
     }
     if (process.env.NODE_ENV === 'production') {
       path = join(`${prefix}/${app_id}/points-${app_id}.json`);
-      console.log('正式服JSON', path);
+      console.log('正式服JSON-move', path);
     }
     this.loadJSON(path);
   }
@@ -207,9 +213,9 @@ export class MoveService implements OnModuleInit {
     angleIndex,
   ) {
 
-    if(angleIndex<0){
+    if (angleIndex < 0) {
       debugger;
-     }
+    }
 
     let moveFramesRes, moveFrames;
     let key =
@@ -1367,20 +1373,20 @@ export class MoveService implements OnModuleInit {
       user.camera.position = JSON.parse(
         JSON.stringify(cameraInfo.camera_position),
       );
-      
+
       user.camera.angle = JSON.parse(
         JSON.stringify(cameraInfo.camera_angle),
       );
 
       this.sendingFrameForJoystick = true;
       return this.reply;
-    } 
-    else if (this.cameraInfos.length == 0){
-      if(this.reply['newUserStates'][0].renderInfo.isMoving == 1){
+    }
+    else if (this.cameraInfos.length == 0) {
+      if (this.reply['newUserStates'][0].renderInfo.isMoving == 1) {
         //console.log('handlejoysticktesttest:complementFrame-2 停止1'+new Date().getTime())
         return this.stopJoystick(userId)
       }
-      else{
+      else {
         //console.log('handlejoysticktesttest:complementFrame-2 停止2'+new Date().getTime())
         return null;
       }
@@ -1445,7 +1451,7 @@ export class MoveService implements OnModuleInit {
     );
     this.reply['newUserStates'][0].playerState.camera.position = JSON.parse(
       JSON.stringify(user.camera.position),
-    ); 
+    );
 
     this.reply['newUserStates'][0].playerState.cameraCenter = JSON.parse(
       JSON.stringify(user.player.position),
@@ -1511,7 +1517,7 @@ export class MoveService implements OnModuleInit {
   getDistance(position1, position2) {
     return Math.sqrt(
       (position1.x - position2.x) * (position1.x - position2.x) +
-        (position1.y - position2.y) * (position1.y - position2.y),
+      (position1.y - position2.y) * (position1.y - position2.y),
     );
   }