duhhhhhhhh
This commit is contained in:
@@ -4,6 +4,9 @@ import { DeviceClass } from "../platforms/types.ts";
|
||||
import Profile from "../profiles/profile.ts";
|
||||
import { type ServerBase } from "../server.ts";
|
||||
import { RoomInstance } from "../instances/types.ts";
|
||||
import Command from "../commands/command.ts";
|
||||
import z from "zod";
|
||||
import { PushNotificationId } from "../socket/signalr/types.ts";
|
||||
|
||||
export enum VRMovementMode {
|
||||
TELEPORT,
|
||||
@@ -33,7 +36,6 @@ export class Presence {
|
||||
|
||||
#statusVisibility: PlayerStatusVisibility = PlayerStatusVisibility.Offline;
|
||||
#deviceClass: DeviceClass = DeviceClass.Unknown;
|
||||
#roomInstance: RoomInstance | null = null;
|
||||
#vrMovementMove: VRMovementMode | undefined;
|
||||
|
||||
#lastExported: Date = new Date();
|
||||
@@ -63,12 +65,16 @@ export class Presence {
|
||||
this.#statusVisibility = sv;
|
||||
this.updateLastSeen();
|
||||
this.update();
|
||||
|
||||
this.#server.emit('presence.update', { profile: this.#profile, presence: this });
|
||||
}
|
||||
|
||||
setVRMovementMode(mm: VRMovementMode) {
|
||||
this.#vrMovementMove = mm;
|
||||
this.updateLastSeen();
|
||||
this.update();
|
||||
|
||||
this.#server.emit('presence.update', { profile: this.#profile, presence: this });
|
||||
}
|
||||
|
||||
getLastExported() {
|
||||
@@ -87,14 +93,14 @@ export class Presence {
|
||||
statusVisibility: this.#statusVisibility,
|
||||
deviceClass: this.#deviceClass,
|
||||
vrMovementMode: this.#vrMovementMove,
|
||||
roomInstance: this.#roomInstance
|
||||
roomInstance: this.#profile.getInstance()?.export() ?? null
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class PresenceBase extends ServerContentBase {
|
||||
export class ServerPresenceBase extends ServerContentBase {
|
||||
|
||||
#log = new Logging("Presence");
|
||||
|
||||
@@ -119,9 +125,32 @@ export class PresenceBase extends ServerContentBase {
|
||||
|
||||
override start() {
|
||||
this.#intervalId = setInterval(() => {
|
||||
if (this.#presenceMap.size === 0) return;
|
||||
|
||||
this.#log.i('Clearing dead presences');
|
||||
this.#deleteDeadPresences();
|
||||
}, 300_000);
|
||||
|
||||
this.server.Commands.addRootCommand(new Command({
|
||||
key: ["presence", "pres"],
|
||||
subcommands: [
|
||||
new Command({
|
||||
key: ["quit", "quitgame"],
|
||||
exec: async (pid: number) => {
|
||||
const prof = await this.server.Profiles.get(pid);
|
||||
if (!prof) return false;
|
||||
|
||||
const socket = prof.getSocketHandler();
|
||||
if (!socket) return false;
|
||||
|
||||
socket.sendNotification(PushNotificationId.ModerationQuitGame);
|
||||
return true;
|
||||
},
|
||||
zod: z.tuple([z.coerce.number()]),
|
||||
help: "Sends ModerationQuitGame to a player's socket if it is connected. Returns true if successful."
|
||||
})
|
||||
]
|
||||
}));
|
||||
}
|
||||
|
||||
override destroy() {
|
||||
|
||||
Reference in New Issue
Block a user