|
@@ -1,10 +1,9 @@
|
|
|
import { Injectable, Logger } from '@nestjs/common';
|
|
|
import { CacheService } from 'src/cache/cache.service';
|
|
|
|
|
|
-
|
|
|
@Injectable()
|
|
|
export class RotateService {
|
|
|
- constructor(private cacheService: CacheService) { }
|
|
|
+ constructor(private cacheService: CacheService) {}
|
|
|
private actionRequestPool = {};
|
|
|
private logger: Logger = new Logger('rotateService');
|
|
|
private Actions = {
|
|
@@ -20,7 +19,7 @@ export class RotateService {
|
|
|
appId: null,
|
|
|
userId: null,
|
|
|
breakPointId: null,
|
|
|
- roomId:null,
|
|
|
+ roomId: null,
|
|
|
player: {
|
|
|
position: { x: -700, y: 0, z: 0 },
|
|
|
angle: {
|
|
@@ -271,9 +270,11 @@ export class RotateService {
|
|
|
user.camera['position'] = value ? value.cameraPosition : '';
|
|
|
user.camera['angle'] = value ? value.cameraAngle : '';
|
|
|
|
|
|
- reply['newUserStates'][0]['playerState'].player.position = user.player.position;
|
|
|
- reply['newUserStates'][0]['playerState'].player.angle = user.player.angle;
|
|
|
-
|
|
|
+ reply['newUserStates'][0]['playerState'].player.position =
|
|
|
+ user.player.position;
|
|
|
+ reply['newUserStates'][0]['playerState'].player.angle =
|
|
|
+ user.player.angle;
|
|
|
+
|
|
|
//this.reply['newUserStates'][0]['playerState'] .player
|
|
|
reply['newUserStates'][0]['playerState'].camera.position =
|
|
|
user.camera['position'];
|
|
@@ -328,92 +329,114 @@ export class RotateService {
|
|
|
return actionResponse;
|
|
|
}
|
|
|
|
|
|
- getNewUserStateRequest(actionRequest){
|
|
|
- try{
|
|
|
+ getNewUserStateRequest(actionRequest) {
|
|
|
+ try {
|
|
|
const userId = actionRequest['user_id'];
|
|
|
- const actionType = actionRequest['actionType'];
|
|
|
+ const actionType = actionRequest['action_type'];
|
|
|
const traceId = actionRequest['trace_id'];
|
|
|
|
|
|
- let reply = {
|
|
|
- "actionType": actionType,
|
|
|
- "pointType": 100,
|
|
|
- "extra": "",
|
|
|
- "traceId": traceId,
|
|
|
- "packetId": "",
|
|
|
- "nps": [],
|
|
|
- "peopleNum": 0,
|
|
|
- "zoneId": "",
|
|
|
- "echoMsg": "",
|
|
|
- "reserveDetail": null,
|
|
|
- "userWithAvatarList": [],
|
|
|
- "newUserStates": [],
|
|
|
- "code": 0,
|
|
|
- "msg": ""
|
|
|
- }
|
|
|
+ const reply = {
|
|
|
+ actionType: actionType,
|
|
|
+ pointType: 100,
|
|
|
+ extra: '',
|
|
|
+ traceId: traceId,
|
|
|
+ packetId: '',
|
|
|
+ nps: [],
|
|
|
+ peopleNum: 0,
|
|
|
+ zoneId: '',
|
|
|
+ echoMsg: '',
|
|
|
+ reserveDetail: null,
|
|
|
+ userWithAvatarList: [],
|
|
|
+ newUserStates: [],
|
|
|
+ code: 0,
|
|
|
+ msg: '',
|
|
|
+ };
|
|
|
|
|
|
- let userIds = Object.keys(this.users);
|
|
|
- for(let i=0;i<userIds.length;++i){
|
|
|
- let _user = this.users[userIds[i]];
|
|
|
- let newUserState = {
|
|
|
- "userId": userIds[i],
|
|
|
- "playerState": {
|
|
|
- "roomTypeId": "",
|
|
|
- "person": 0,
|
|
|
- "avatarId": "KGe_Boy",
|
|
|
- "skinId": "10089",
|
|
|
- "roomId": "e629ef3e-022d-4e64-8654-703bb96410eb",
|
|
|
- "isHost": false,
|
|
|
- "isFollowHost": false,
|
|
|
- "skinDataVersion": "1008900008",
|
|
|
- "avatarComponents": "",
|
|
|
- "nickName": userIds[i],
|
|
|
- "movingMode": 0,
|
|
|
- "attitude": "walk",
|
|
|
- "areaName": "",
|
|
|
- "pathName": "thirdwalk",
|
|
|
- "pathId": "thirdwalk",
|
|
|
- "avatarSize": 1,
|
|
|
- "extra": "{\"removeWhenDisconnected\":true}",
|
|
|
- "prioritySync": false,
|
|
|
- "player": {
|
|
|
- "position": _user.player.position,
|
|
|
- "angle": _user.player.angle
|
|
|
+ const userIds = Object.keys(this.users);
|
|
|
+ for (let i = 0; i < userIds.length; ++i) {
|
|
|
+ const _user = this.users[userIds[i]];
|
|
|
+ const newUserState = {
|
|
|
+ userId: userIds[i],
|
|
|
+ playerState: {
|
|
|
+ roomTypeId: '',
|
|
|
+ person: 0,
|
|
|
+ avatarId: 'KGe_Boy',
|
|
|
+ skinId: '10089',
|
|
|
+ roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
|
|
|
+ isHost: false,
|
|
|
+ isFollowHost: false,
|
|
|
+ skinDataVersion: '1008900008',
|
|
|
+ avatarComponents: '',
|
|
|
+ nickName: userIds[i],
|
|
|
+ movingMode: 0,
|
|
|
+ attitude: 'walk',
|
|
|
+ areaName: '',
|
|
|
+ pathName: 'thirdwalk',
|
|
|
+ pathId: 'thirdwalk',
|
|
|
+ avatarSize: 1,
|
|
|
+ extra: '{"removeWhenDisconnected":true}',
|
|
|
+ prioritySync: false,
|
|
|
+ player: {
|
|
|
+ position: _user.player.position,
|
|
|
+ angle: _user.player.angle,
|
|
|
},
|
|
|
- "camera": null,
|
|
|
- "cameraCenter": null
|
|
|
+ camera: null,
|
|
|
+ cameraCenter: null,
|
|
|
},
|
|
|
- "renderInfo": {
|
|
|
- "renderType": 0,
|
|
|
- "videoFrame": null,
|
|
|
- "cameraStateType": 0,
|
|
|
- "isMoving": 0,
|
|
|
- "needIfr": 0,
|
|
|
- "isVideo": 0,
|
|
|
- "stillFrame": 0,
|
|
|
- "isRotating": 0,
|
|
|
- "isFollowing": 0,
|
|
|
- "clientPanoTitlesBitmap": [],
|
|
|
- "clientPanoTreceId": "",
|
|
|
- "prefetchVideoId": "",
|
|
|
- "noMedia": false
|
|
|
+ renderInfo: {
|
|
|
+ renderType: 0,
|
|
|
+ videoFrame: null,
|
|
|
+ cameraStateType: 0,
|
|
|
+ isMoving: 0,
|
|
|
+ needIfr: 0,
|
|
|
+ isVideo: 0,
|
|
|
+ stillFrame: 0,
|
|
|
+ isRotating: 0,
|
|
|
+ isFollowing: 0,
|
|
|
+ clientPanoTitlesBitmap: [],
|
|
|
+ clientPanoTreceId: '',
|
|
|
+ prefetchVideoId: '',
|
|
|
+ noMedia: false,
|
|
|
},
|
|
|
- "event": {
|
|
|
- "id": "",
|
|
|
- "type": 0,
|
|
|
- "points": [],
|
|
|
- "rotateEvent": null,
|
|
|
- "removeVisitorEvent": null
|
|
|
+ event: {
|
|
|
+ id: '',
|
|
|
+ type: 0,
|
|
|
+ points: [],
|
|
|
+ rotateEvent: null,
|
|
|
+ removeVisitorEvent: null,
|
|
|
},
|
|
|
- "relation": 0
|
|
|
+ relation: 0,
|
|
|
};
|
|
|
|
|
|
- reply["newUserStates"].push(newUserState);
|
|
|
+ reply['newUserStates'].push(newUserState);
|
|
|
}
|
|
|
|
|
|
return reply;
|
|
|
- }
|
|
|
- catch(error){
|
|
|
+ } catch (error) {
|
|
|
this.logger.error('getNewUserStateRequest::function', error);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async ech(userId) {
|
|
|
+ const user = this.users[userId];
|
|
|
+ const reply = JSON.parse(JSON.stringify(this.replies[userId]));
|
|
|
+ reply['newUserStates'][0]['userId'] = userId;
|
|
|
+ reply['newUserStates'][0]['playerState'].player.position = user.player.position;
|
|
|
+ reply['newUserStates'][0]['playerState'].player.angle = user.player.angle;
|
|
|
+ reply['newUserStates'][0]['playerState'].camera.position = user.camera['position'];
|
|
|
+ reply['newUserStates'][0]['playerState'].camera.angle = user.camera['angle'];
|
|
|
+ reply['newUserStates'][0]['playerState'].cameraCenter = user.player.position;
|
|
|
+
|
|
|
+ const key ='rotateframe:app_id:' +user.appId +':frame_index:' + user.rotateInfo.frameIndex +':break_point_id:' +user.breakPointId;
|
|
|
+ const redisData = await this.cacheService.get(key);
|
|
|
+ if (redisData && redisData.length > 0) {
|
|
|
+ const value = redisData ? JSON.parse(redisData) : null;
|
|
|
+ reply.mediaSrc ='/' +'0000000001' +'/' +user.breakPointId +'/' +value.directory +'/' +value.fileName +'?m=' +new Date().getTime();
|
|
|
+ return reply;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|