test pc %!s(int64=3) %!d(string=hai) anos
pai
achega
9ad533fdbc
Modificáronse 1 ficheiros con 32 adicións e 12 borrados
  1. 32 12
      src/move/move.service.ts

+ 32 - 12
src/move/move.service.ts

@@ -12,8 +12,8 @@ import configuration from 'src/config/configuration';
 
 
 const MaxDelayTime = 80; //超过这个值就需要干预(操作杆)
 const MaxDelayTime = 80; //超过这个值就需要干预(操作杆)
 const MaxBufferCameraInfo = 3; //超过这个值就需要干预(操作杆)
 const MaxBufferCameraInfo = 3; //超过这个值就需要干预(操作杆)
-const MaxNet = 3;
-const MaxWalkCount = 20;
+const MaxNet = 30000000;
+const MaxWalkCount = 2;
 
 
 const seqExeAsyncFn = (asyncFn) => {
 const seqExeAsyncFn = (asyncFn) => {
   let runPromise = null;
   let runPromise = null;
@@ -685,6 +685,7 @@ export class MoveService implements OnModuleInit {
       const breakPointId = user.breakPointId;
       const breakPointId = user.breakPointId;
       const appId = user.appId;
       const appId = user.appId;
       const replys = [];
       const replys = [];
+      console.log('joystickActionRequest=>'+traceId+'_'+new Date().getTime());
       let step = 0.4;
       let step = 0.4;
       if(user.walkState>MaxWalkCount){
       if(user.walkState>MaxWalkCount){
         step = 1.2;
         step = 1.2;
@@ -788,21 +789,37 @@ export class MoveService implements OnModuleInit {
         }
         }
       }
       }
       console.log('joystickjoystick:' + this.cameraInfos.length);
       console.log('joystickjoystick:' + this.cameraInfos.length);
+      this.reply.actionResponses[0].actionType = actionType;
       //超出范围了
       //超出范围了
       if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
       if (this.getDistance(playerPosition, breakPoint.position) > closestDis) {
-        return await this.moveCamera(
-          breakPointId,
-          closestNeighorId,
-          appId,
-          userId,
-          traceId,
-          actionType,
-        );
+        if (user.lastJoyStickMediaSrc) {
+          user.player.position = JSON.parse(JSON.stringify(playerPosition));
+          this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
+            JSON.stringify(user.player.position),
+          );
+          user.lastJoyStickMediaSrc = false;
+          console.log('joystickActionRequest_1=>'+traceId+'_'+new Date().getTime());
+          return this.reply;
+        }
+        else{
+          return await this.moveCamera(
+            breakPointId,
+            closestNeighorId,
+            appId,
+            userId,
+            traceId,
+            actionType,
+          );
+        }
       } else {
       } else {
         const inside = this.isPointInPoly(playerPosition, area);
         const inside = this.isPointInPoly(playerPosition, area);
         //超出区域
         //超出区域
         if (!inside) {
         if (!inside) {
           if (minAngleNeighorId != null) {
           if (minAngleNeighorId != null) {
+            if (user.lastJoyStickMediaSrc) {
+              user.lastJoyStickMediaSrc = false;
+              return null;
+            }
             return await this.moveDirect(
             return await this.moveDirect(
               playerPosition,
               playerPosition,
               closestDis,
               closestDis,
@@ -822,10 +839,9 @@ export class MoveService implements OnModuleInit {
         this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
         this.reply['newUserStates'][0].playerState.player.position = JSON.parse(
           JSON.stringify(user.player.position),
           JSON.stringify(user.player.position),
         );
         );
-        this.reply.actionResponses[0].actionType = actionType;
 
 
         console.log('20220719_延时->' + time_delay);
         console.log('20220719_延时->' + time_delay);
-        // //网络延迟的情况下,就暂时不推流
+        //网络延迟的情况下,就暂时不推流
         if (
         if (
           time_delay &&
           time_delay &&
           time_delay < MaxDelayTime &&
           time_delay < MaxDelayTime &&
@@ -840,9 +856,11 @@ export class MoveService implements OnModuleInit {
         if (user.netQua < MaxNet) {
         if (user.netQua < MaxNet) {
           if (user.lastJoyStickMediaSrc) {
           if (user.lastJoyStickMediaSrc) {
             user.lastJoyStickMediaSrc = false;
             user.lastJoyStickMediaSrc = false;
+            console.log('joystickActionRequest_1=>'+traceId+'_'+new Date().getTime());
             return this.reply;
             return this.reply;
           }
           }
         }
         }
+        
         const cameraInfo = this.getCameraInfo();
         const cameraInfo = this.getCameraInfo();
         if (cameraInfo != null) {
         if (cameraInfo != null) {
           this.reply['newUserStates'][0].playerState.camera.position =
           this.reply['newUserStates'][0].playerState.camera.position =
@@ -853,6 +871,7 @@ export class MoveService implements OnModuleInit {
           if (cameraInfo.mediaSrc) {
           if (cameraInfo.mediaSrc) {
             this.reply.mediaSrc = cameraInfo.mediaSrc;
             this.reply.mediaSrc = cameraInfo.mediaSrc;
             this.reply.isIDR = cameraInfo.isIDR;
             this.reply.isIDR = cameraInfo.isIDR;
+            console.log('joystickActionRequest_2=>'+traceId+'_'+new Date().getTime());
             user.lastJoyStickMediaSrc = true;
             user.lastJoyStickMediaSrc = true;
           }
           }
 
 
@@ -1439,6 +1458,7 @@ export class MoveService implements OnModuleInit {
   }
   }
 
 
   complementFrame(userId) {
   complementFrame(userId) {
+    debugger;
     const user = this.users[userId];
     const user = this.users[userId];
     user.walkState = 0;
     user.walkState = 0;
     user.IDRCount = 0;
     user.IDRCount = 0;