Merge branch 'develop' into changeRegisterAccess
Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> # Conflicts: # front/src/Connexion/ConnectionManager.ts # front/vite.config.ts
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
FollowConfirmationMessage,
|
||||
FollowAbortMessage,
|
||||
VariableMessage,
|
||||
LockGroupPromptMessage,
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import { UserMovesMessage } from "../Messages/generated/messages_pb";
|
||||
import { parse } from "query-string";
|
||||
@@ -37,7 +38,7 @@ import { InvalidTokenError } from "../Controller/InvalidTokenError";
|
||||
import HyperExpress from "hyper-express";
|
||||
import { localWokaService } from "../Services/LocalWokaService";
|
||||
import { WebSocket } from "uWebSockets.js";
|
||||
import { WokaDetail } from "../Enum/PlayerTextures";
|
||||
import { WokaDetail } from "../Messages/JsonMessages/PlayerTextures";
|
||||
|
||||
/**
|
||||
* The object passed between the "open" and the "upgrade" methods when opening a websocket
|
||||
@@ -561,6 +562,11 @@ export class IoSocketController {
|
||||
);
|
||||
} else if (message.hasFollowabortmessage()) {
|
||||
socketManager.handleFollowAbort(client, message.getFollowabortmessage() as FollowAbortMessage);
|
||||
} else if (message.hasLockgrouppromptmessage()) {
|
||||
socketManager.handleLockGroup(
|
||||
client,
|
||||
message.getLockgrouppromptmessage() as LockGroupPromptMessage
|
||||
);
|
||||
}
|
||||
|
||||
/* Ok is false if backpressure was built up, wait for drain */
|
||||
|
||||
@@ -88,6 +88,14 @@ export class MapController extends BaseHttpController {
|
||||
* type: boolean|undefined
|
||||
* description: Whether the "report" feature is enabled or not on this room
|
||||
* example: true
|
||||
* loadingLogo:
|
||||
* type: string
|
||||
* description: The URL of the image to be used on the loading page
|
||||
* example: https://example.com/logo.png
|
||||
* loginSceneLogo:
|
||||
* type: string
|
||||
* description: The URL of the image to be used on the LoginScene
|
||||
* example: https://example.com/logo_login.png
|
||||
*
|
||||
*/
|
||||
this.app.get("/map", (req, res) => {
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import * as tg from "generic-type-guard";
|
||||
import { z } from "zod";
|
||||
|
||||
//The list of all the player textures, both the default models and the partial textures used for customization
|
||||
|
||||
const wokaTexture = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
url: z.string(),
|
||||
tags: z.array(z.string()).optional(),
|
||||
tintable: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export type WokaTexture = z.infer<typeof wokaTexture>;
|
||||
|
||||
const wokaTextureCollection = z.object({
|
||||
name: z.string(),
|
||||
textures: z.array(wokaTexture),
|
||||
});
|
||||
|
||||
export type WokaTextureCollection = z.infer<typeof wokaTextureCollection>;
|
||||
|
||||
const wokaPartType = z.object({
|
||||
collections: z.array(wokaTextureCollection),
|
||||
required: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export type WokaPartType = z.infer<typeof wokaPartType>;
|
||||
|
||||
export const wokaList = z.record(wokaPartType);
|
||||
|
||||
export type WokaList = z.infer<typeof wokaList>;
|
||||
|
||||
export const wokaPartNames = ["woka", "body", "eyes", "hair", "clothes", "hat", "accessory"];
|
||||
|
||||
export const isWokaDetail = new tg.IsInterface()
|
||||
.withProperties({
|
||||
id: tg.isString,
|
||||
})
|
||||
.withOptionalProperties({
|
||||
url: tg.isString,
|
||||
layer: tg.isString,
|
||||
})
|
||||
.get();
|
||||
|
||||
export type WokaDetail = tg.GuardedType<typeof isWokaDetail>;
|
||||
|
||||
export type WokaDetailsResult = WokaDetail[];
|
||||
@@ -92,8 +92,10 @@ export class PositionDispatcher {
|
||||
|
||||
public removeViewport(socket: ExSocketInterface): void {
|
||||
// Also, let's stop listening on viewports
|
||||
for (const zone of socket.listenedZones) {
|
||||
this.stopListening(zone, socket);
|
||||
if (socket.listenedZones) {
|
||||
for (const zone of socket.listenedZones) {
|
||||
this.stopListening(zone, socket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import { ClientDuplexStream } from "grpc";
|
||||
import { Zone } from "_Model/Zone";
|
||||
import { compressors } from "hyper-express";
|
||||
import { WokaDetail } from "_Enum/PlayerTextures";
|
||||
import { WokaDetail } from "../../Messages/JsonMessages/PlayerTextures";
|
||||
|
||||
export type BackConnection = ClientDuplexStream<PusherToBackMessage, ServerToClientMessage>;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { ExSocketInterface } from "_Model/Websocket/ExSocketInterface";
|
||||
import Direction = PositionMessage.Direction;
|
||||
import { ItemEventMessageInterface } from "_Model/Websocket/ItemEventMessage";
|
||||
import { PositionInterface } from "_Model/PositionInterface";
|
||||
import { WokaDetail } from "_Enum/PlayerTextures";
|
||||
import { WokaDetail } from "../../Messages/JsonMessages/PlayerTextures";
|
||||
|
||||
export class ProtobufUtils {
|
||||
public static toPositionMessage(point: PointInterface): PositionMessage {
|
||||
|
||||
@@ -123,19 +123,25 @@ export class UserDescriptor {
|
||||
}
|
||||
|
||||
export class GroupDescriptor {
|
||||
private constructor(public readonly groupId: number, private groupSize: number, private position: PointMessage) {}
|
||||
private constructor(
|
||||
public readonly groupId: number,
|
||||
private groupSize: number,
|
||||
private position: PointMessage,
|
||||
private locked: boolean
|
||||
) {}
|
||||
|
||||
public static createFromGroupUpdateZoneMessage(message: GroupUpdateZoneMessage): GroupDescriptor {
|
||||
const position = message.getPosition();
|
||||
if (position === undefined) {
|
||||
throw new Error("Missing position");
|
||||
}
|
||||
return new GroupDescriptor(message.getGroupid(), message.getGroupsize(), position);
|
||||
return new GroupDescriptor(message.getGroupid(), message.getGroupsize(), position, message.getLocked());
|
||||
}
|
||||
|
||||
public update(groupDescriptor: GroupDescriptor) {
|
||||
this.groupSize = groupDescriptor.groupSize;
|
||||
this.position = groupDescriptor.position;
|
||||
this.locked = groupDescriptor.locked;
|
||||
}
|
||||
|
||||
public toGroupUpdateMessage(): GroupUpdateMessage {
|
||||
@@ -146,7 +152,7 @@ export class GroupDescriptor {
|
||||
groupUpdateMessage.setGroupid(this.groupId);
|
||||
groupUpdateMessage.setGroupsize(this.groupSize);
|
||||
groupUpdateMessage.setPosition(this.position);
|
||||
|
||||
groupUpdateMessage.setLocked(this.locked);
|
||||
return groupUpdateMessage;
|
||||
}
|
||||
}
|
||||
@@ -206,9 +212,7 @@ export class Zone {
|
||||
this.notifyGroupMove(groupDescriptor);
|
||||
} else {
|
||||
this.groups.set(groupId, groupDescriptor);
|
||||
|
||||
const fromZone = groupUpdateZoneMessage.getFromzone();
|
||||
|
||||
this.notifyGroupEnter(groupDescriptor, fromZone?.toObject());
|
||||
}
|
||||
} else if (message.hasUserleftzonemessage()) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { ADMIN_API_TOKEN, ADMIN_API_URL, ADMIN_URL, OPID_PROFILE_SCREEN_PROVIDER } from "../Enum/EnvironmentVariable";
|
||||
import Axios, { AxiosResponse } from "axios";
|
||||
import { MapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||
import { RoomRedirect } from "../Messages/JsonMessages/RoomRedirect";
|
||||
import { isMapDetailsData, MapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||
import { isRoomRedirect, RoomRedirect } from "../Messages/JsonMessages/RoomRedirect";
|
||||
import { AdminApiData, isAdminApiData } from "../Messages/JsonMessages/AdminApiData";
|
||||
import * as tg from "generic-type-guard";
|
||||
import { isNumber } from "generic-type-guard";
|
||||
import { isWokaDetail } from "../Enum/PlayerTextures";
|
||||
import { isWokaDetail } from "../Messages/JsonMessages/PlayerTextures";
|
||||
import qs from "qs";
|
||||
|
||||
export interface AdminBannedData {
|
||||
@@ -46,10 +46,16 @@ class AdminApi {
|
||||
userId,
|
||||
};
|
||||
|
||||
const res = await Axios.get(ADMIN_API_URL + "/api/map", {
|
||||
const res = await Axios.get<unknown, AxiosResponse<unknown>>(ADMIN_API_URL + "/api/map", {
|
||||
headers: { Authorization: `${ADMIN_API_TOKEN}` },
|
||||
params,
|
||||
});
|
||||
if (!isMapDetailsData(res.data) && !isRoomRedirect(res.data)) {
|
||||
throw new Error(
|
||||
"Invalid answer received from the admin for the /api/map endpoint. Received: " +
|
||||
JSON.stringify(res.data)
|
||||
);
|
||||
}
|
||||
return res.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import axios, { AxiosResponse } from "axios";
|
||||
import { ADMIN_API_TOKEN, ADMIN_API_URL } from "../Enum/EnvironmentVariable";
|
||||
import { wokaList, WokaList } from "../Enum/PlayerTextures";
|
||||
import { wokaList, WokaList } from "../Messages/JsonMessages/PlayerTextures";
|
||||
import { WokaServiceInterface } from "./WokaServiceInterface";
|
||||
|
||||
class AdminWokaService implements WokaServiceInterface {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { WokaDetail, WokaDetailsResult, WokaList, wokaPartNames } from "../Enum/PlayerTextures";
|
||||
import { WokaDetail, WokaDetailsResult, WokaList, wokaPartNames } from "../Messages/JsonMessages/PlayerTextures";
|
||||
import { WokaServiceInterface } from "./WokaServiceInterface";
|
||||
|
||||
class LocalWokaService implements WokaServiceInterface {
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
ErrorMessage,
|
||||
WorldFullMessage,
|
||||
PlayerDetailsUpdatedMessage,
|
||||
LockGroupPromptMessage,
|
||||
InvalidTextureMessage,
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
||||
@@ -297,6 +298,12 @@ export class SocketManager implements ZoneEventListener {
|
||||
client.backConnection.write(pusherToBackMessage);
|
||||
}
|
||||
|
||||
handleLockGroup(client: ExSocketInterface, message: LockGroupPromptMessage): void {
|
||||
const pusherToBackMessage = new PusherToBackMessage();
|
||||
pusherToBackMessage.setLockgrouppromptmessage(message);
|
||||
client.backConnection.write(pusherToBackMessage);
|
||||
}
|
||||
|
||||
onEmote(emoteMessage: EmoteEventMessage, listener: ExSocketInterface): void {
|
||||
const subMessage = new SubMessage();
|
||||
subMessage.setEmoteeventmessage(emoteMessage);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { WokaDetailsResult, WokaList } from "../Enum/PlayerTextures";
|
||||
import { WokaList } from "../Messages/JsonMessages/PlayerTextures";
|
||||
|
||||
export interface WokaServiceInterface {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user