|
@@ -9,6 +9,7 @@ import { statSync, createReadStream, readFileSync } from 'fs';
|
|
import { Readable } from 'stream';
|
|
import { Readable } from 'stream';
|
|
import { BehaviorSubject } from 'rxjs';
|
|
import { BehaviorSubject } from 'rxjs';
|
|
import * as streamBuffers from 'stream-buffers';
|
|
import * as streamBuffers from 'stream-buffers';
|
|
|
|
+import { ActionType } from './actionType';
|
|
|
|
|
|
@Injectable()
|
|
@Injectable()
|
|
export class SceneService implements OnModuleInit {
|
|
export class SceneService implements OnModuleInit {
|
|
@@ -36,40 +37,23 @@ export class SceneService implements OnModuleInit {
|
|
return this.sceneGrpcService.getBreakPoint(request);
|
|
return this.sceneGrpcService.getBreakPoint(request);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ test(request: TestRequest) {
|
|
|
|
+ return this.sceneGrpcService.test(request);
|
|
|
|
+ }
|
|
|
|
+
|
|
init(request: string) {
|
|
init(request: string) {
|
|
try {
|
|
try {
|
|
- console.log('request', this.sceneGrpcService);
|
|
|
|
|
|
+ // console.log('request', this.sceneGrpcService);
|
|
const params = JSON.parse(request);
|
|
const params = JSON.parse(request);
|
|
// const requestData: InitRequest = {
|
|
// const requestData: InitRequest = {
|
|
// appId: params.appId
|
|
// appId: params.appId
|
|
// }
|
|
// }
|
|
- const demo_test: InitRequest = {
|
|
|
|
- user_id: '92dd7e2f-cca9-495d-8f16-458e628ea827',
|
|
|
|
- nick_name: 'Hello',
|
|
|
|
- skin_id: 'ce098a8f-a7fc-4721-9c37-31bdbc580c59',
|
|
|
|
- avatar_id: 'c961561e-78e5-4478-b158-944e3b9c9287',
|
|
|
|
- room_id: 'c38187b6-d4af-44bb-8028-7ad1e5461cd8',
|
|
|
|
- app_id: '2282e1b5-6129-4e0d-a30b-2339a1c761cd',
|
|
|
|
- player: {
|
|
|
|
- position: {
|
|
|
|
- x: '0.0',
|
|
|
|
- y: '0.0',
|
|
|
|
- z: '0.0',
|
|
|
|
- },
|
|
|
|
- angle: {
|
|
|
|
- pitch: 10,
|
|
|
|
- yaw: 10,
|
|
|
|
- roll: 10,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- };
|
|
|
|
- const name = {
|
|
|
|
- name: 'Hello',
|
|
|
|
- };
|
|
|
|
- const initReply = this.sceneGrpcService.test(name);
|
|
|
|
- // initReply.subscribe((val) => {
|
|
|
|
- // console.log('val', val);
|
|
|
|
- // });
|
|
|
|
|
|
+ this.logger.log('init', request);
|
|
|
|
+ const rpcRequest: InitRequest = params;
|
|
|
|
+ const initReply = this.sceneGrpcService.init(rpcRequest);
|
|
|
|
+ initReply.subscribe((reply) => {
|
|
|
|
+ console.log('initReply', reply);
|
|
|
|
+ });
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.log('error', error);
|
|
console.log('error', error);
|
|
}
|
|
}
|
|
@@ -80,7 +64,10 @@ export class SceneService implements OnModuleInit {
|
|
}
|
|
}
|
|
|
|
|
|
rotate(request: RotateRequest) {
|
|
rotate(request: RotateRequest) {
|
|
- return this.sceneGrpcService.rotate(request);
|
|
|
|
|
|
+ const reply = this.sceneGrpcService.rotate(request);
|
|
|
|
+ reply.subscribe((res) => {
|
|
|
|
+ console.log('rotate-reply', res);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
joystick(request: JoystickRequest) {
|
|
joystick(request: JoystickRequest) {
|
|
@@ -98,8 +85,25 @@ export class SceneService implements OnModuleInit {
|
|
this.onSteaming.next(false);
|
|
this.onSteaming.next(false);
|
|
}
|
|
}
|
|
|
|
|
|
- handleMessage(event: string | Buffer) {
|
|
|
|
- console.log('get rtc message', event);
|
|
|
|
|
|
+ handleMessage(message: string | Buffer) {
|
|
|
|
+ try {
|
|
|
|
+ if (typeof message === 'string') {
|
|
|
|
+ const msg: RTCMessageRequest = JSON.parse(message);
|
|
|
|
+ switch (msg.action_type) {
|
|
|
|
+ case ActionType.rotate:
|
|
|
|
+ console.log('rotate', msg);
|
|
|
|
+ const rotateRequest: RotateRequest = msg;
|
|
|
|
+ this.rotate(rotateRequest);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // console.log('get rtc message', message);
|
|
|
|
+ } catch (error) {
|
|
|
|
+ this.logger.error('handleMessage:rtc', error);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
handleStartCountingFrame() {
|
|
handleStartCountingFrame() {
|
|
this._frameInteval = setInterval(async () => {
|
|
this._frameInteval = setInterval(async () => {
|
|
@@ -167,7 +171,7 @@ export class SceneService implements OnModuleInit {
|
|
console.log('首屏--数据');
|
|
console.log('首屏--数据');
|
|
const paths = path.join(__dirname, '../ws/video');
|
|
const paths = path.join(__dirname, '../ws/video');
|
|
// const clipPath = paths + `/1.v2.h264`;
|
|
// const clipPath = paths + `/1.v2.h264`;
|
|
- const testClipPath = paths + `/2.h264`;
|
|
|
|
|
|
+ const testClipPath = paths + `/254.h264`;
|
|
const metaData = {
|
|
const metaData = {
|
|
traceIds: [],
|
|
traceIds: [],
|
|
vehicle: null,
|
|
vehicle: null,
|