Further the login process

* Matchmaking login locks (created and checked only in memory for now)
* Profile reputation temporary implementation
* Profiles now no longer initialize if a user with the same username is found
* vrMovementMode in presence is now required, falls back to 'Teleport'
* Progression implementation began
* API routes: Settings, player subscriptions, reputation, progression
* cropSquare in image query is not a boolean, rather a number representing a boolean
* Hile reporting uses forms, not json
* Presence heartbeat and logout
* Socket changes: Close event listener (destroy), send message function, targets further started
This commit is contained in:
2025-03-29 23:09:40 -04:00
parent 1af0206b6a
commit 026f9c8bd8
22 changed files with 294 additions and 56 deletions

View File

@@ -34,17 +34,17 @@ export class SignalRSocketHandler {
#onMessage(message: Message) {
if (message.kind == MessageKind.Protocol) {
this.#send({});
this.sendRaw({});
return;
} else {
this.#log.d(`CLIENT MESSAGE\n Type: ${message.data.type} (${SignalMessageType[message.data.type - 1]})\n ${JSON.stringify(message.data)}`);
this.#log.d(`CLIENT MESSAGE\n Type: ${message.data.type} (${SignalMessageType[message.data.type]})\n ${JSON.stringify(message.data)}`);
}
}
async #init() {
this.#log.source += this.#profile.getId().toString();
this.#log.i(`Player '${(await this.#profile.export())?.username}' (${this.#profile.getId()}) created hub socket`);
this.#log.i(`Created hub socket`);
this.#socket.addEventListener('message', message => {
try {
@@ -68,9 +68,19 @@ export class SignalRSocketHandler {
this.#log.e(`Socket error: ${err}`);
}
});
this.#socket.addEventListener('close', this.destroy(this));
}
#send(data: object) {
destroy(sock: SignalRSocketHandler) {
return () => {
sock.sendRaw({ type: 7, error: "Socket closed by server" });
sock.#socket.close();
sock.#log.i(`Closed hub socket`);
}
}
sendRaw(data: object) {
this.#socket.send(`${JSON.stringify(data)}\u001e`);
}

View File

@@ -110,7 +110,8 @@ export const SignalRMessageSchema = z.discriminatedUnion("type", [
export enum TargetResultType {
Success,
Failure
Failure,
NotATarget
}
interface TargetResultBase {
type: TargetResultType
@@ -122,4 +123,7 @@ export interface TargetResultSuccess<T = unknown> extends TargetResultBase {
export interface TargetResultFailure extends TargetResultBase {
type: TargetResultType.Failure
}
export type TargetResult = TargetResultSuccess | TargetResultFailure;
export interface TargetResultNotATarget extends TargetResultBase {
type: TargetResultType.NotATarget
}
export type TargetResult = TargetResultSuccess | TargetResultFailure | TargetResultNotATarget;