import { Controller, Get, OnModuleInit } from '@nestjs/common';
import { AppService } from './app.service';
// import { UtilsModule } from '@app/utils';
import { grpcClientOptions } from './grpc-scene.options';

import { ClientGrpc, Client } from '@nestjs/microservices';

interface Point {
  x: string;
  y: string;
  z: string;
}
@Controller()
export class AppController implements OnModuleInit {
  @Client(grpcClientOptions) private readonly client: ClientGrpc;
  private sceneGrpcService: SceneGrpcService;

  constructor(private readonly appService: AppService) {}

  onModuleInit() {
    // console.log('this.client', this.client);
    this.sceneGrpcService =
      this.client.getService<SceneGrpcService>('SceneGrpcService');
  }
  @Get()
  getHello(): string {
    // console.log('UtilsModule', UtilsModule);
    const params: RouteRequest = {
      sLocation: {
        x: '6.0',
        y: '0.0',
        z: '-4.0',
      },
      eLocation: {
        x: '4.0',
        y: '0.0',
        z: '-3.0',
      },
      sceneCode: 'Hello',
    };
    // console.log('params', params);
    const test = this.sceneGrpcService.getRoute(params);
    test.subscribe((val) => {
      console.log('val', val);
    });
    return this.appService.getHello();
  }
}
