|
@@ -8,27 +8,30 @@ import MessageHandleType from "./enum/MessageHandleType.js"
|
|
|
|
|
|
const logger = new Logger('actions-handler')
|
|
const logger = new Logger('actions-handler')
|
|
const QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
|
|
const QueueActions = [Actions.Transfer, Actions.ChangeSkin, Actions.GetOnVehicle, Actions.GetOffVehicle];
|
|
|
|
+
|
|
export default class ActionsHandler {
|
|
export default class ActionsHandler {
|
|
- constructor(e) {
|
|
|
|
|
|
+ constructor(room) {
|
|
this.currentActiveAction = null
|
|
this.currentActiveAction = null
|
|
- this.room = e
|
|
|
|
|
|
+ this.room = room
|
|
}
|
|
}
|
|
|
|
|
|
- async avatarComponentsSync(e){
|
|
|
|
- const t = {
|
|
|
|
- action_type: Actions.SetPlayerState,
|
|
|
|
- set_player_state_action: {
|
|
|
|
- player_state: {
|
|
|
|
- avatar_components: JSON.stringify(e)
|
|
|
|
|
|
+ async avatarComponentsSync(avatarComponents) {
|
|
|
|
+ this.sendData({
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.SetPlayerState,
|
|
|
|
+ set_player_state_action: {
|
|
|
|
+ player_state: {
|
|
|
|
+ avatar_components: JSON.stringify(avatarComponents)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- };
|
|
|
|
- this.sendData({
|
|
|
|
- data: t
|
|
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
- async sendData(actionData) {
|
|
|
|
|
|
+ async sendData(actionData)
|
|
|
|
+ {
|
|
|
|
+ console.error("[Action]", Actions[actionData.data.action_type])
|
|
|
|
+
|
|
await this.beforeSend(actionData);
|
|
await this.beforeSend(actionData);
|
|
const traceId = util.uuid();
|
|
const traceId = util.uuid();
|
|
this.room.networkController.sendRtcData(le(oe({}, actionData.data), {
|
|
this.room.networkController.sendRtcData(le(oe({}, actionData.data), {
|
|
@@ -40,6 +43,7 @@ export default class ActionsHandler {
|
|
{
|
|
{
|
|
return Promise.resolve(null);
|
|
return Promise.resolve(null);
|
|
}
|
|
}
|
|
|
|
+
|
|
const { sampleRate=1, timeout=2e3, tag, data, special } = actionData;
|
|
const { sampleRate=1, timeout=2e3, tag, data, special } = actionData;
|
|
return eventsManager.track({
|
|
return eventsManager.track({
|
|
timeout,
|
|
timeout,
|
|
@@ -56,7 +60,8 @@ export default class ActionsHandler {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
- async beforeSend(e) {
|
|
|
|
|
|
+ async beforeSend(e)
|
|
|
|
+ {
|
|
var o;
|
|
var o;
|
|
const t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving
|
|
const t = (o = this.room._userAvatar) == null ? void 0 : o.isMoving
|
|
, r = e.data.action_type;
|
|
, r = e.data.action_type;
|
|
@@ -74,182 +79,210 @@ export default class ActionsHandler {
|
|
logger.error("before action stopMoving failed", a)
|
|
logger.error("before action stopMoving failed", a)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- async moveTo(e) {
|
|
|
|
- const {point: t, extra: r="", motionType: n} = e
|
|
|
|
- , o = {
|
|
|
|
- action_type: Actions.Clicking,
|
|
|
|
- clicking_action: {
|
|
|
|
- clicking_point: t,
|
|
|
|
- clicking_type: ClickType.IgnoreView,
|
|
|
|
- extra: encodeURIComponent(r),
|
|
|
|
- attitude: n
|
|
|
|
- },
|
|
|
|
- clicking_state: this.room._currentClickingState
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 点击行走至某一点时执行
|
|
|
|
+ async moveTo({point, extra="", motionType})
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: o
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.Clicking,
|
|
|
|
+ clicking_action: {
|
|
|
|
+ clicking_point: point,
|
|
|
|
+ clicking_type: ClickType.IgnoreView,
|
|
|
|
+ extra: encodeURIComponent(extra),
|
|
|
|
+ attitude: motionType
|
|
|
|
+ },
|
|
|
|
+ clicking_state: this.room._currentClickingState
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- transfer(e) {
|
|
|
|
- const {renderType: t, player: r, camera: n, areaName: o, attitude: a, pathName: s, person: l, noMedia: u, timeout: c, tag: h, special: f} = e
|
|
|
|
- , d = {
|
|
|
|
|
|
+
|
|
|
|
+ transfer({renderType, player, camera, areaName, attitude, pathName, person:personType, noMedia, timeout, tag, special})
|
|
|
|
+ {
|
|
|
|
+ return this.sendData({
|
|
data: {
|
|
data: {
|
|
action_type: Actions.Transfer,
|
|
action_type: Actions.Transfer,
|
|
transfer_action: {
|
|
transfer_action: {
|
|
- render_type: t,
|
|
|
|
- player: r,
|
|
|
|
- camera: n,
|
|
|
|
- areaName: o,
|
|
|
|
- attitude: a,
|
|
|
|
- pathName: s,
|
|
|
|
|
|
+ render_type: renderType,
|
|
|
|
+ player,
|
|
|
|
+ camera,
|
|
|
|
+ areaName,
|
|
|
|
+ attitude,
|
|
|
|
+ pathName,
|
|
person: {
|
|
person: {
|
|
- type: l
|
|
|
|
|
|
+ type: personType
|
|
},
|
|
},
|
|
- noMedia: u,
|
|
|
|
|
|
+ noMedia,
|
|
tiles: [0, 1, 2, 4]
|
|
tiles: [0, 1, 2, 4]
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- special: f,
|
|
|
|
- timeout: c || 4e3,
|
|
|
|
- tag: h
|
|
|
|
- };
|
|
|
|
- return this.sendData(d).then(_=>(typeof l != "undefined" && this.room.updateCurrentNetworkOptions({
|
|
|
|
- person: l,
|
|
|
|
- rotationRenderType: t
|
|
|
|
- }),
|
|
|
|
- _))
|
|
|
|
- }
|
|
|
|
- changeRotationRenderType(e) {
|
|
|
|
- const {renderType: t, player: r, camera: n, areaName: o, attitude: a, pathName: s} = e;
|
|
|
|
|
|
+ special,
|
|
|
|
+ timeout: timeout || 4e3,
|
|
|
|
+ tag
|
|
|
|
+ }).then(_ => (
|
|
|
|
+ typeof personType != "undefined" && this.room.updateCurrentNetworkOptions({
|
|
|
|
+ person: personType,
|
|
|
|
+ rotationRenderType: renderType
|
|
|
|
+ }),
|
|
|
|
+ _
|
|
|
|
+ ))
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Panorama.exit()中调用
|
|
|
|
+ changeRotationRenderType({renderType, player, camera, areaName, attitude, pathName})
|
|
|
|
+ {
|
|
return this.transfer({
|
|
return this.transfer({
|
|
- renderType: t,
|
|
|
|
- player: r,
|
|
|
|
- camera: n,
|
|
|
|
- areaName: o,
|
|
|
|
- attitude: a,
|
|
|
|
- pathName: s,
|
|
|
|
|
|
+ renderType,
|
|
|
|
+ player,
|
|
|
|
+ camera,
|
|
|
|
+ areaName,
|
|
|
|
+ attitude,
|
|
|
|
+ pathName,
|
|
tag: "changeToRotationVideo"
|
|
tag: "changeToRotationVideo"
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- requestPanorama(e, noMedia, timeout) {
|
|
|
|
- const {camera: camera, player: player, areaName: areaName, attitude: attitude, pathName: pathName, tag: tag} = e;
|
|
|
|
|
|
+
|
|
|
|
+ // 用于请求第一人称视角下的pano数据
|
|
|
|
+ requestPanorama({camera, player, areaName, attitude, pathName, tag}, noMedia, timeout)
|
|
|
|
+ {
|
|
return this.transfer({
|
|
return this.transfer({
|
|
renderType: RenderType.ClientRotationPano,
|
|
renderType: RenderType.ClientRotationPano,
|
|
- player: player,
|
|
|
|
- camera: camera,
|
|
|
|
|
|
+ player,
|
|
|
|
+ camera,
|
|
person: Person.First,
|
|
person: Person.First,
|
|
- areaName: areaName,
|
|
|
|
- attitude: attitude,
|
|
|
|
- pathName: pathName,
|
|
|
|
|
|
+ areaName,
|
|
|
|
+ attitude,
|
|
|
|
+ pathName,
|
|
noMedia: noMedia,
|
|
noMedia: noMedia,
|
|
timeout: timeout,
|
|
timeout: timeout,
|
|
tag: tag || "requestPanorama",
|
|
tag: tag || "requestPanorama",
|
|
special: !noMedia
|
|
special: !noMedia
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- setMotionType(e) {
|
|
|
|
|
|
+
|
|
|
|
+ // 设置角色行动类型,如MotionType.Walk。方法未调用
|
|
|
|
+ setMotionType(type)
|
|
|
|
+ {
|
|
return this.transfer({
|
|
return this.transfer({
|
|
- attitude: e,
|
|
|
|
|
|
+ attitude: type,
|
|
tag: "setMotionType"
|
|
tag: "setMotionType"
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- setNickName(e) {
|
|
|
|
- const t = {
|
|
|
|
- action_type: Actions.ChangeNickname,
|
|
|
|
- change_nickname_action: {
|
|
|
|
- nickname: e
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 设置角色昵称
|
|
|
|
+ setNickName(nickname)
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: t
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.ChangeNickname,
|
|
|
|
+ change_nickname_action: {
|
|
|
|
+ nickname
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- getReserveSeat({routeId: e, name: t}) {
|
|
|
|
- const r = {
|
|
|
|
- action_type: Actions.ReserveSeat,
|
|
|
|
- reserve_seat_action: {
|
|
|
|
- route_id: e,
|
|
|
|
- name: t
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 方法未调用
|
|
|
|
+ getReserveSeat({routeId, name})
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: r
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.ReserveSeat,
|
|
|
|
+ reserve_seat_action: {
|
|
|
|
+ route_id: routeId,
|
|
|
|
+ name
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- getReserveStatus({routeId: e, name: t, need_detail: r}) {
|
|
|
|
- const n = {
|
|
|
|
- action_type: Actions.GetReserveStatus,
|
|
|
|
- get_reserve_status_action: {
|
|
|
|
- route_id: e,
|
|
|
|
- name: t,
|
|
|
|
- need_detail: r
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 方法未调用
|
|
|
|
+ getReserveStatus({routeId, name, need_detail})
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: n,
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.GetReserveStatus,
|
|
|
|
+ get_reserve_status_action: {
|
|
|
|
+ route_id: routeId,
|
|
|
|
+ name,
|
|
|
|
+ need_detail
|
|
|
|
+ }
|
|
|
|
+ },
|
|
timeout: 2e3
|
|
timeout: 2e3
|
|
}).then(o=>o.reserveDetail)
|
|
}).then(o=>o.reserveDetail)
|
|
}
|
|
}
|
|
- stopMoving() {
|
|
|
|
- const e = {
|
|
|
|
- action_type: Actions.StopMoving,
|
|
|
|
- stop_move_action: {}
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 停止移动。目前只在playAnimation时调用
|
|
|
|
+ stopMoving()
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: e
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.StopMoving,
|
|
|
|
+ stop_move_action: {}
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- getOnVehicle({routeId: e, name: t, camera: r}) {
|
|
|
|
- const n = {
|
|
|
|
- action_type: Actions.GetOnVehicle,
|
|
|
|
- get_on_vehicle_action: {
|
|
|
|
- route_id: e,
|
|
|
|
- name: t,
|
|
|
|
- camera: r
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 方法未调用
|
|
|
|
+ getOnVehicle({routeId, name, camera})
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: n
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.GetOnVehicle,
|
|
|
|
+ get_on_vehicle_action: {
|
|
|
|
+ route_id: routeId,
|
|
|
|
+ name,
|
|
|
|
+ camera
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- getOffVehicle({renderType: e, player: t, camera: r}) {
|
|
|
|
- const n = {
|
|
|
|
- action_type: Actions.GetOffVehicle,
|
|
|
|
- get_off_vehicle_action: {
|
|
|
|
- render_type: e,
|
|
|
|
- player: t,
|
|
|
|
- camera: r
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 方法未调用
|
|
|
|
+ getOffVehicle({renderType, player, camera})
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: n
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.GetOffVehicle,
|
|
|
|
+ get_off_vehicle_action: {
|
|
|
|
+ render_type: renderType,
|
|
|
|
+ player,
|
|
|
|
+ camera
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- confirmEvent(e) {
|
|
|
|
- const t = {
|
|
|
|
- action_type: Actions.ConfirmEvent,
|
|
|
|
- confirm_event_action: {
|
|
|
|
- id: e
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 目前只在_handleAvatar时调用
|
|
|
|
+ confirmEvent(id)
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: t,
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.ConfirmEvent,
|
|
|
|
+ confirm_event_action: {
|
|
|
|
+ id
|
|
|
|
+ }
|
|
|
|
+ },
|
|
track: !1
|
|
track: !1
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- echo(e) {
|
|
|
|
- const t = {
|
|
|
|
- action_type: Actions.Echo,
|
|
|
|
- echo_msg: {
|
|
|
|
- echoMsg: e
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 心跳
|
|
|
|
+ echo(echoMsg)
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: t,
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.Echo,
|
|
|
|
+ echo_msg: {
|
|
|
|
+ echoMsg
|
|
|
|
+ }
|
|
|
|
+ },
|
|
track: !1
|
|
track: !1
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- async changeSkin(e) {
|
|
|
|
|
|
+
|
|
|
|
+ async changeSkin(e)
|
|
|
|
+ {
|
|
const t = e.special === void 0 ? e.renderType === RenderType.ClientRotationPano : e.special
|
|
const t = e.special === void 0 ? e.renderType === RenderType.ClientRotationPano : e.special
|
|
, {skinId: r, mode: n, landingType: o=LandingType.Stay, landingPoint: a, landingCamera: s, renderType: l, areaName: u, attitude: c, pathName: h, person: f, noMedia: d, timeout: _, roomTypeId: g=""} = e
|
|
, {skinId: r, mode: n, landingType: o=LandingType.Stay, landingPoint: a, landingCamera: s, renderType: l, areaName: u, attitude: c, pathName: h, person: f, noMedia: d, timeout: _, roomTypeId: g=""} = e
|
|
, m = this.room.skinList.filter(y=>y.id === r)[0];
|
|
, m = this.room.skinList.filter(y=>y.id === r)[0];
|
|
@@ -292,7 +325,9 @@ export default class ActionsHandler {
|
|
}
|
|
}
|
|
).catch(y=>d ? this.handleChangeSkin(e) : Promise.reject(y))
|
|
).catch(y=>d ? this.handleChangeSkin(e) : Promise.reject(y))
|
|
}
|
|
}
|
|
- handleChangeSkin(e) {
|
|
|
|
|
|
+
|
|
|
|
+ handleChangeSkin(e)
|
|
|
|
+ {
|
|
const {skinId: t, mode: r, renderType: n, areaName: o, attitude: a, pathName: s} = e;
|
|
const {skinId: t, mode: r, renderType: n, areaName: o, attitude: a, pathName: s} = e;
|
|
return this.room.sceneManager.staticmeshComponent.getCgMesh().show(),
|
|
return this.room.sceneManager.staticmeshComponent.getCgMesh().show(),
|
|
this.room.sceneManager.cameraComponent.switchToCgCamera(),
|
|
this.room.sceneManager.cameraComponent.switchToCgCamera(),
|
|
@@ -317,205 +352,219 @@ export default class ActionsHandler {
|
|
}
|
|
}
|
|
)
|
|
)
|
|
}
|
|
}
|
|
- rotate({pitch: e, yaw: t}) {
|
|
|
|
- var n;
|
|
|
|
- if (this.room.disableRotate || this.room.isPano || ((n = this.room._userAvatar) == null ? void 0 : n._isChangingComponentsMode))
|
|
|
|
- return;
|
|
|
|
- const r = {
|
|
|
|
- action_type: Actions.Rotation,
|
|
|
|
- rotation_action: {
|
|
|
|
- vertical_move: e,
|
|
|
|
- horizontal_move: -t
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 相机旋转
|
|
|
|
+ rotate({pitch, yaw})
|
|
|
|
+ {
|
|
|
|
+ if (
|
|
|
|
+ this.room.disableRotate ||
|
|
|
|
+ this.room.isPano ||
|
|
|
|
+ (this.room._userAvatar == null ? void 0 : this.room._userAvatar._isChangingComponentsMode)
|
|
|
|
+ ) return;
|
|
|
|
+
|
|
this.sendData({
|
|
this.sendData({
|
|
- data: r,
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.Rotation,
|
|
|
|
+ rotation_action: {
|
|
|
|
+ vertical_move: pitch,
|
|
|
|
+ horizontal_move: -yaw
|
|
|
|
+ }
|
|
|
|
+ },
|
|
sampleRate: .02
|
|
sampleRate: .02
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- turnTo(e) {
|
|
|
|
- const {point: t, timeout: r=2e3, offset: n=8} = e || {}
|
|
|
|
- , o = {
|
|
|
|
- action_type: Actions.TurnTo,
|
|
|
|
- turn_to_action: {
|
|
|
|
- turn_to_point: t,
|
|
|
|
- offset: n
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ turnTo({point, timeout=2e3, offset=8} = {})
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: o,
|
|
|
|
- timeout: r
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.TurnTo,
|
|
|
|
+ turn_to_action: {
|
|
|
|
+ turn_to_point: point,
|
|
|
|
+ offset
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ timeout
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- rotateTo(e) {
|
|
|
|
- const {point: t, offset: r=0, speed: n=3} = e || {}
|
|
|
|
- , o = {
|
|
|
|
- action_type: Actions.RotateTo,
|
|
|
|
- rotate_to_action: {
|
|
|
|
- rotate_to_point: t,
|
|
|
|
- offset: r,
|
|
|
|
- speed: n
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ rotateTo({point, offset=0, speed=3} = {})
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: o
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.RotateTo,
|
|
|
|
+ rotate_to_action: {
|
|
|
|
+ rotate_to_point: point,
|
|
|
|
+ offset,
|
|
|
|
+ speed
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- broadcast(e) {
|
|
|
|
- const {data: t, msgType: r=MessageHandleType.MHT_FollowListMulticast, targetUserIds: n} = e;
|
|
|
|
- if (r === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(n))
|
|
|
|
- return Promise.reject(new ParamError(`param targetUserIds is required when msgType is ${MessageHandleType[r]}`));
|
|
|
|
- const o = {
|
|
|
|
|
|
+
|
|
|
|
+ broadcast({data, msgType=MessageHandleType.MHT_FollowListMulticast, targetUserIds})
|
|
|
|
+ {
|
|
|
|
+ if (msgType === MessageHandleType.MHT_CustomTargetSync && !Array.isArray(targetUserIds))
|
|
|
|
+ return Promise.reject(new ParamError(`param targetUserIds is required when msgType is ${MessageHandleType[msgType]}`));
|
|
|
|
+
|
|
|
|
+ let sendData = {
|
|
action_type: Actions.Broadcast,
|
|
action_type: Actions.Broadcast,
|
|
broadcast_action: {
|
|
broadcast_action: {
|
|
- data: JSON.stringify(t),
|
|
|
|
|
|
+ data: JSON.stringify(data),
|
|
user_id: this.room.options.userId,
|
|
user_id: this.room.options.userId,
|
|
- msgType: r
|
|
|
|
|
|
+ msgType
|
|
}
|
|
}
|
|
- };
|
|
|
|
- return Array.isArray(n) && r === MessageHandleType.MHT_CustomTargetSync && (o.broadcast_action.target_user_ids = n),
|
|
|
|
- this.room.actionsHandler.sendData({
|
|
|
|
- data: o,
|
|
|
|
- tag: t.broadcastType
|
|
|
|
|
|
+ }
|
|
|
|
+ if (msgType === MessageHandleType.MHT_CustomTargetSync && Array.isArray(targetUserIds)) {
|
|
|
|
+ sendData.broadcast_action.target_user_ids = targetUserIds
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return this.room.actionsHandler.sendData({
|
|
|
|
+ data: sendData,
|
|
|
|
+ tag: data.broadcastType
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- getNeighborPoints(e) {
|
|
|
|
- const {point: t, containSelf: r=!1, searchRange: n=500} = e
|
|
|
|
- , o = {
|
|
|
|
- action_type: Actions.GetNeighborPoints,
|
|
|
|
- get_neighbor_points_action: {
|
|
|
|
- point: t,
|
|
|
|
- level: 1,
|
|
|
|
- containSelf: r,
|
|
|
|
- searchRange: n
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ getNeighborPoints({point, containSelf=!1, searchRange=500})
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: o
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.GetNeighborPoints,
|
|
|
|
+ get_neighbor_points_action: {
|
|
|
|
+ point,
|
|
|
|
+ level: 1,
|
|
|
|
+ containSelf,
|
|
|
|
+ searchRange
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}).then(a=>a.nps)
|
|
}).then(a=>a.nps)
|
|
}
|
|
}
|
|
- playCG(e) {
|
|
|
|
- const t = {
|
|
|
|
- action_type: Actions.PlayCG,
|
|
|
|
- play_cg_action: {
|
|
|
|
- cg_name: e
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ playCG(cgName)
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: t
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.PlayCG,
|
|
|
|
+ play_cg_action: {
|
|
|
|
+ cg_name: cgName
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- audienceToVisitor(e) {
|
|
|
|
- const {avatarId: t, avatarComponents: r, player: n, camera: o} = e
|
|
|
|
- , a = {
|
|
|
|
- action_type: Actions.AudienceChangeToVisitor,
|
|
|
|
- audienceChangeToVisitorAction: {
|
|
|
|
- avatarID: t,
|
|
|
|
- avatarComponents: r,
|
|
|
|
- player: n,
|
|
|
|
- camera: o
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ audienceToVisitor({avatarId, avatarComponents, player, camera})
|
|
|
|
+ {
|
|
return logger.debug("send data: audience to visitor"),
|
|
return logger.debug("send data: audience to visitor"),
|
|
this.sendData({
|
|
this.sendData({
|
|
- data: a
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- visitorToAudience(e) {
|
|
|
|
- const {renderType: t, player: r, camera: n, areaName: o, attitude: a, pathName: s, person: l, noMedia: u} = e
|
|
|
|
- , c = {
|
|
|
|
- action_type: Actions.VisitorChangeToAudience,
|
|
|
|
- visitorChangeToAudienceAction: {
|
|
|
|
- transferAction: {
|
|
|
|
- render_type: t,
|
|
|
|
- player: r,
|
|
|
|
- camera: n,
|
|
|
|
- areaName: o,
|
|
|
|
- attitude: a,
|
|
|
|
- pathName: s,
|
|
|
|
- person: {
|
|
|
|
- type: l
|
|
|
|
- },
|
|
|
|
- noMedia: u,
|
|
|
|
- tiles: [0, 1, 2, 4]
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.AudienceChangeToVisitor,
|
|
|
|
+ audienceChangeToVisitorAction: {
|
|
|
|
+ avatarID: avatarId,
|
|
|
|
+ avatarComponents,
|
|
|
|
+ player,
|
|
|
|
+ camera
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- };
|
|
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ visitorToAudience({renderType, player, camera, areaName, attitude, pathName, person:personType, noMedia})
|
|
|
|
+ {
|
|
return logger.debug("send data: visitor to audience"),
|
|
return logger.debug("send data: visitor to audience"),
|
|
this.sendData({
|
|
this.sendData({
|
|
- data: c
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.VisitorChangeToAudience,
|
|
|
|
+ visitorChangeToAudienceAction: {
|
|
|
|
+ transferAction: {
|
|
|
|
+ render_type: renderType,
|
|
|
|
+ player,
|
|
|
|
+ camera,
|
|
|
|
+ areaName,
|
|
|
|
+ attitude,
|
|
|
|
+ pathName,
|
|
|
|
+ person: {
|
|
|
|
+ type: personType
|
|
|
|
+ },
|
|
|
|
+ noMedia,
|
|
|
|
+ tiles: [0, 1, 2, 4]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- removeVisitor(e) {
|
|
|
|
- const {removeType: t, userIDList: r, extraInfo: n=""} = e
|
|
|
|
- , o = {
|
|
|
|
- action_type: Actions.RemoveVisitor,
|
|
|
|
- removeVisitorAction: {
|
|
|
|
- removeVisitorEvent: t,
|
|
|
|
- userIDList: r,
|
|
|
|
- extraInfo: encodeURIComponent(n)
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ removeVisitor({removeType, userIDList, extraInfo=""})
|
|
|
|
+ {
|
|
return logger.debug("send data: remove visitor"),
|
|
return logger.debug("send data: remove visitor"),
|
|
this.sendData({
|
|
this.sendData({
|
|
- data: o
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.RemoveVisitor,
|
|
|
|
+ removeVisitorAction: {
|
|
|
|
+ removeVisitorEvent: removeType,
|
|
|
|
+ userIDList,
|
|
|
|
+ extraInfo: encodeURIComponent(extraInfo)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- getUserWithAvatar(e, t) {
|
|
|
|
- const r = {
|
|
|
|
- action_type: Actions.GetUserWithAvatar,
|
|
|
|
- getUserWithAvatarAction: {
|
|
|
|
- userType: e,
|
|
|
|
- roomID: t
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ getUserWithAvatar(userType, roomID)
|
|
|
|
+ {
|
|
return logger.debug("send data: get user with avatar"),
|
|
return logger.debug("send data: get user with avatar"),
|
|
this.sendData({
|
|
this.sendData({
|
|
- data: r
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.GetUserWithAvatar,
|
|
|
|
+ getUserWithAvatarAction: {
|
|
|
|
+ userType,
|
|
|
|
+ roomID
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}).then(n=>n.userWithAvatarList)
|
|
}).then(n=>n.userWithAvatarList)
|
|
}
|
|
}
|
|
- getNewUserState(e) {
|
|
|
|
- const i = {
|
|
|
|
- action_type: Actions.GetNewUserState,
|
|
|
|
- getNewUserStateAction: {
|
|
|
|
- userType: e
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ getNewUserState(userType)
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: i,
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.GetNewUserState,
|
|
|
|
+ getNewUserStateAction: {
|
|
|
|
+ userType
|
|
|
|
+ }
|
|
|
|
+ },
|
|
sampleRate: 0
|
|
sampleRate: 0
|
|
}).then(o => o)
|
|
}).then(o => o)
|
|
}
|
|
}
|
|
- setSyncPolicy({
|
|
|
|
- syncPolicy: e
|
|
|
|
- }) {
|
|
|
|
- const i = {
|
|
|
|
- action_type: Actions.SetSyncPolicy,
|
|
|
|
- setSyncPolicyAction: {
|
|
|
|
- syncPolicy: e
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ setSyncPolicy({syncPolicy})
|
|
|
|
+ {
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: i
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.SetSyncPolicy,
|
|
|
|
+ setSyncPolicyAction: {
|
|
|
|
+ syncPolicy
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- joystick(e) {
|
|
|
|
- const {degree: t, level: r=1} = e
|
|
|
|
- , n = util.uuid();
|
|
|
|
- let o = -t + 90 + 360;
|
|
|
|
- o >= 360 && (o -= 360);
|
|
|
|
- const a = {
|
|
|
|
- action_type: Actions.Joystick,
|
|
|
|
- dir_action: {
|
|
|
|
- move_angle: o,
|
|
|
|
- speed_level: r
|
|
|
|
- },
|
|
|
|
- trace_id: n,
|
|
|
|
- user_id: this.room.options.userId,
|
|
|
|
- packet_id: n
|
|
|
|
- };
|
|
|
|
|
|
+
|
|
|
|
+ // 拖动手柄
|
|
|
|
+ joystick({degree, level=1})
|
|
|
|
+ {
|
|
|
|
+ const uuid = util.uuid();
|
|
|
|
+ let angle = -degree + 90 + 360;
|
|
|
|
+ angle >= 360 && (angle -= 360);
|
|
|
|
+
|
|
return this.sendData({
|
|
return this.sendData({
|
|
- data: a,
|
|
|
|
|
|
+ data: {
|
|
|
|
+ action_type: Actions.Joystick,
|
|
|
|
+ dir_action: {
|
|
|
|
+ move_angle: angle,
|
|
|
|
+ speed_level: level
|
|
|
|
+ },
|
|
|
|
+ trace_id: uuid,
|
|
|
|
+ user_id: this.room.options.userId,
|
|
|
|
+ packet_id: uuid
|
|
|
|
+ },
|
|
track: !1
|
|
track: !1
|
|
})
|
|
})
|
|
}
|
|
}
|