gemercheung пре 3 година
родитељ
комит
d5696f6447
5 измењених фајлова са 71 додато и 36 уклоњено
  1. 40 25
      proto/scene.proto
  2. 4 3
      src/meta.gateway.ts
  3. 1 1
      src/scene/grpc-scene.options.ts
  4. 25 4
      src/scene/scene.d.ts
  5. 1 3
      src/scene/scene.service.ts

+ 40 - 25
proto/scene.proto

@@ -7,22 +7,17 @@ option java_package = "com.fdkk.fdkkmeta.grpc";
 
 // grpc的方法
 service SceneGrpcService {
-  rpc test (TestRequest) returns (TestReply){}
   rpc getRoute (RouteRequest) returns (RouteReply){}
-  rpc init (InitRequest) returns (NormalReply){}
+  rpc init (InitRequest) returns (CommonReply){}
   rpc rotate (RotateRequest) returns (NormalReply){}
+  rpc move (MoveRequest) returns (NormalReply){}
 //  rpc moveStart (StartMoveRequest) returns (MoveReply){}
 //  rpc moveProcess (MoveNextNeighborRequest) returns (MoveReply){}
   rpc echo (EchoRequest) returns (EchoReply){}
   rpc usersState (GetNewUserStateRequest) returns (GetNewUserStateReply){}
   rpc getBreakPoint (BreakPointRequest) returns (BreakPointReply){}
   rpc joystick (JoystickRequest) returns (NormalReply){} //操作杆
-}
-message TestRequest {
-  string name=3;
-}
-message TestReply {
-  bool msg=3;
+  rpc exit(ExitRequest) returns (NormalReply){}
 }
 // 全局对象
 message Point {
@@ -100,7 +95,7 @@ message State {
    string pathName=14;
    string pathId=15;
    int32 avatarSize=16;
-   Extra extra=17;
+   string extra=17;
    bool prioritySync=18;
    Space player=19;
    Space camera=20;
@@ -143,12 +138,28 @@ message UserState{
 // init入参对象
 message InitRequest {
   string user_id=1;
-  string nick_name=2;
-  string skin_id=3;
-  string avatar_id=4;
-  string room_id=5;
-  string app_id=6;
-  Space player=7;
+  string roomId=2;
+  string avatar_id=3;
+  string skin_id=4;
+  bool is_host=5;
+  string skin_data_version=6;
+  int32 rotation_render_type=7;
+  bool is_all_sync=8;
+  string nick_name=9;
+  string app_id=10;
+  Space camera=11;
+  Space player=12;
+  int32 person=13;
+  string firends=14;
+  bool sync_by_event=15;
+  string area_name=16;
+  string path_name=17;
+  string attitude=18;
+  string room_type_id=19;
+  bool syncToOthers=20;
+  bool hasAvatar=21;
+  bool prioritySync=22;
+  string extra=23;
 }
 /**********************************************************/
 message EchoMsg{
@@ -224,16 +235,15 @@ message RotateRequest {
 }
 /**********************************************************/
 //正常的反馈
-//message NormalReply {
-//   repeated string traceIds=1;
-//   string vehicle=2;
-//   repeated UserState newUserStates=3;
-//   repeated int32 actionResponses=4;
-//   int32 getStateType=5;
-//   int32 code=6;
-//   string msg=7;
-//   string frameSrc=8;              //视频路径
-//}
+message CommonReply {
+   repeated string traceIds=1;
+   string vehicle=2;
+   repeated UserState newUserStates=3;
+   repeated int32 actionResponses=4;
+   int32 getStateType=5;
+   int32 code=6;
+   string msg=7;
+}
 
 /**********************************************************/
 //
@@ -334,3 +344,8 @@ message BreakPointReply {
   string msg=14;
 }
 /**********************************************************/
+message ExitRequest{
+  int32 action_type=1;                                           //1002
+  string user_id=2;
+  string trace_id=3;
+}

+ 4 - 3
src/meta.gateway.ts

@@ -34,11 +34,12 @@ initLogger('Debug');
   path: '/ws',
 })
 export class MetaGateway
-  implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect {
+  implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect
+{
   constructor(
     private readonly sceneService: SceneService,
     private readonly configService: ConfigService,
-  ) { }
+  ) {}
   private logger: Logger = new Logger('MetaGateway');
   private peer: PeerConnection = null;
   private timer: NodeJS.Timeout;
@@ -317,7 +318,7 @@ export class MetaGateway
         }
         // debugger
       });
-    } catch (error) { }
+    } catch (error) {}
   }
 
   handleConnection(client: WebSocket, ...args: any[]) {

+ 1 - 1
src/scene/grpc-scene.options.ts

@@ -9,7 +9,7 @@ export const grpcClientOptions: ClientOptions = {
     package: 'scene',
     protoPath: join(__dirname, '..', 'proto/scene.proto'),
     loader: {
-      keepCase: false,
+      keepCase: true,
     },
   },
 };

+ 25 - 4
src/scene/scene.d.ts

@@ -10,9 +10,9 @@ interface SceneGrpcService {
 }
 
 interface Point {
-  x: string;
-  y: string;
-  z: string;
+  x: number;
+  y: number;
+  z: number;
 }
 interface Angle {
   pitch: number;
@@ -38,9 +38,30 @@ interface InitRequest {
   nick_name: string;
   skin_id: string;
   avatar_id: string;
-  room_id: string;
+  // room_id: string;
   app_id: string;
   player: Player;
+  is_host: boolean;
+  skin_data_version: string;
+  rotation_render_type: number;
+  is_all_sync: true;
+  camera: {
+    position: Point;
+    angle: Angle;
+  };
+  person: number;
+  sync_by_event: boolean;
+  firends: string;
+  area_name: string;
+  path_name: string;
+  attitude: string;
+  room_type_id: string;
+  syncToOthers: boolean;
+  hasAvatar: boolean;
+  prioritySync: boolean;
+  extra: string;
+  user_id: string;
+  roomId: string;
 }
 
 interface RotateRequest {

+ 1 - 3
src/scene/scene.service.ts

@@ -13,7 +13,7 @@ import { CacheService } from 'src/cache/cache.service';
 
 @Injectable()
 export class SceneService implements OnModuleInit {
-  constructor(private cacheService: CacheService) { }
+  constructor(private cacheService: CacheService) {}
   @Client(grpcClientOptions) private readonly client: ClientGrpc;
   private sceneGrpcService: SceneGrpcService;
 
@@ -45,8 +45,6 @@ export class SceneService implements OnModuleInit {
 
   init(request: InitRequest) {
     try {
-      // this.logger.log('rtc::init::start', JSON.stringify(request));
-
       const initReply = this.sceneGrpcService.init(request);
       initReply.subscribe((reply) => {
         console.log('initReply', reply);