Merge branch 'develop' into 2daysLimit
Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com> # Conflicts: # front/src/Connexion/ConnectionManager.ts
This commit is contained in:
commit
df3c618ffa
82 changed files with 3145 additions and 465 deletions
|
@ -11,6 +11,9 @@ import { loginSceneVisibleIframeStore } from "../Stores/LoginSceneStore";
|
|||
import { userIsConnected, warningContainerStore } from "../Stores/MenuStore";
|
||||
import { analyticsClient } from "../Administration/AnalyticsClient";
|
||||
import { axiosWithRetry } from "./AxiosUtils";
|
||||
import axios from "axios";
|
||||
import { isRegisterData } from "../Messages/JsonMessages/RegisterData";
|
||||
import { isAdminApiData } from "../Messages/JsonMessages/AdminApiData";
|
||||
import {limitMapStore} from "../Stores/GameStore";
|
||||
import {showLimitRoomModalStore} from "../Stores/ModalStore";
|
||||
|
||||
|
@ -127,6 +130,10 @@ class ConnectionManager {
|
|||
const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then(
|
||||
(res) => res.data
|
||||
);
|
||||
if (!isRegisterData(data)) {
|
||||
console.error("Invalid data received from /register route. Data: ", data);
|
||||
throw new Error("Invalid data received from /register route.");
|
||||
}
|
||||
this.localUser = new LocalUser(data.userUuid, data.textures, data.email);
|
||||
this.authToken = data.authToken;
|
||||
localUserStore.saveUser(this.localUser);
|
||||
|
@ -195,11 +202,13 @@ class ConnectionManager {
|
|||
analyticsClient.loggedWithSso();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
//if user must to be connect in current room or pusher error is not openid provier access error
|
||||
//try to connected with function loadOpenIDScreen
|
||||
// if the user must be connected in the current room or if the pusher error is not openid provider access error
|
||||
// try to connect with function loadOpenIDScreen
|
||||
if (
|
||||
this._currentRoom.authenticationMandatory ||
|
||||
(err.response?.data && err.response.data !== "User cannot to be connected on openid provier")
|
||||
(axios.isAxiosError(err) &&
|
||||
err.response?.data &&
|
||||
err.response.data !== "User cannot to be connected on openid provider")
|
||||
) {
|
||||
this.loadOpenIDScreen();
|
||||
return Promise.reject(new Error("You will be redirect on login page"));
|
||||
|
@ -337,7 +346,9 @@ class ConnectionManager {
|
|||
}
|
||||
const { authToken, userUuid, textures, email } = await Axios.get(`${PUSHER_URL}/login-callback`, {
|
||||
params: { code, nonce, token, playUri: this.currentRoom?.key },
|
||||
}).then((res) => res.data);
|
||||
}).then((res) => {
|
||||
return res.data;
|
||||
});
|
||||
localUserStore.setAuthToken(authToken);
|
||||
this.localUser = new LocalUser(userUuid, textures, email);
|
||||
localUserStore.saveUser(this.localUser);
|
||||
|
|
|
@ -18,6 +18,7 @@ export enum EventMessage {
|
|||
GROUP_DELETE = "group-delete",
|
||||
SET_PLAYER_DETAILS = "set-player-details", // Send the name and character to the server (on connect), receive back the id.
|
||||
ITEM_EVENT = "item-event",
|
||||
USER_DETAILS_UPDATED = "user-details-updated",
|
||||
|
||||
CONNECT_ERROR = "connect_error",
|
||||
CONNECTING_ERROR = "connecting_error",
|
||||
|
@ -64,6 +65,7 @@ export interface MessageUserJoined {
|
|||
visitCardUrl: string | null;
|
||||
companion: string | null;
|
||||
userUuid: string;
|
||||
outlineColor: number | undefined;
|
||||
}
|
||||
|
||||
export interface PositionInterface {
|
||||
|
@ -102,6 +104,12 @@ export interface ItemEventMessageInterface {
|
|||
parameters: unknown;
|
||||
}
|
||||
|
||||
export interface PlayerDetailsUpdatedMessageInterface {
|
||||
userId: number;
|
||||
outlineColor: number;
|
||||
removeOutlineColor: boolean;
|
||||
}
|
||||
|
||||
export interface RoomJoinedMessageInterface {
|
||||
//users: MessageUserPositionInterface[],
|
||||
//groups: GroupCreatedUpdatedMessageInterface[],
|
||||
|
|
|
@ -5,6 +5,8 @@ import type { CharacterTexture } from "./LocalUser";
|
|||
import { localUserStore } from "./LocalUserStore";
|
||||
import axios from "axios";
|
||||
import { axiosWithRetry } from "./AxiosUtils";
|
||||
import { isMapDetailsData } from "../Messages/JsonMessages/MapDetailsData";
|
||||
import { isRoomRedirect } from "../Messages/JsonMessages/RoomRedirect";
|
||||
|
||||
export class MapDetail {
|
||||
constructor(public readonly mapUrl: string, public readonly textures: CharacterTexture[] | undefined) {}
|
||||
|
@ -80,7 +82,7 @@ export class Room {
|
|||
const currentRoom = new Room(baseUrl);
|
||||
let instance: string = "global";
|
||||
if (currentRoom.isPublic) {
|
||||
instance = currentRoom.instance as string;
|
||||
instance = currentRoom.getInstance();
|
||||
}
|
||||
|
||||
baseUrl.pathname = "/_/" + instance + "/" + absoluteExitSceneUrl.host + absoluteExitSceneUrl.pathname;
|
||||
|
@ -101,27 +103,33 @@ export class Room {
|
|||
});
|
||||
|
||||
const data = result.data;
|
||||
if (data.redirectUrl) {
|
||||
|
||||
if (isRoomRedirect(data.redirectUrl)) {
|
||||
return {
|
||||
redirectUrl: data.redirectUrl as string,
|
||||
};
|
||||
} else if (isMapDetailsData(data)) {
|
||||
console.log("Map ", this.id, " resolves to URL ", data.mapUrl);
|
||||
this._mapUrl = data.mapUrl;
|
||||
this._textures = data.textures;
|
||||
this._group = data.group;
|
||||
this._authenticationMandatory =
|
||||
data.authenticationMandatory != null ? data.authenticationMandatory : DISABLE_ANONYMOUS;
|
||||
this._iframeAuthentication = data.iframeAuthentication || OPID_LOGIN_SCREEN_PROVIDER;
|
||||
this._contactPage = data.contactPage || CONTACT_URL;
|
||||
return new MapDetail(data.mapUrl, data.textures);
|
||||
} else {
|
||||
throw new Error("Data received by the /map endpoint of the Pusher is not in a valid format.");
|
||||
}
|
||||
console.log("Map ", this.id, " resolves to URL ", data.mapUrl);
|
||||
this._mapUrl = data.mapUrl;
|
||||
this._textures = data.textures;
|
||||
this._group = data.group;
|
||||
this._authenticationMandatory =
|
||||
data.authenticationMandatory != null ? data.authenticationMandatory : DISABLE_ANONYMOUS;
|
||||
this._iframeAuthentication = data.iframeAuthentication || OPID_LOGIN_SCREEN_PROVIDER;
|
||||
this._contactPage = data.contactPage || CONTACT_URL;
|
||||
return new MapDetail(data.mapUrl, data.textures);
|
||||
} catch (e) {
|
||||
if (axios.isAxiosError(e) && e.response?.status == 401 && e.response?.data === "Token decrypted error") {
|
||||
console.warn("JWT token sent could not be decrypted. Maybe it expired?");
|
||||
localUserStore.setAuthToken(null);
|
||||
window.location.assign("/login");
|
||||
} else {
|
||||
} else if (axios.isAxiosError(e)) {
|
||||
console.error("Error => getMapDetail", e, e.response);
|
||||
} else {
|
||||
console.error("Error => getMapDetail", e);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import {
|
|||
BanUserMessage,
|
||||
VariableMessage,
|
||||
ErrorMessage,
|
||||
PlayerDetailsUpdatedMessage,
|
||||
} from "../Messages/generated/messages_pb";
|
||||
|
||||
import type { UserSimplePeerInterface } from "../WebRtc/SimplePeer";
|
||||
|
@ -45,6 +46,7 @@ import {
|
|||
ItemEventMessageInterface,
|
||||
MessageUserJoined,
|
||||
OnConnectInterface,
|
||||
PlayerDetailsUpdatedMessageInterface,
|
||||
PlayGlobalMessageInterface,
|
||||
PositionInterface,
|
||||
RoomJoinedMessageInterface,
|
||||
|
@ -172,6 +174,9 @@ export class RoomConnection implements RoomConnection {
|
|||
} else if (subMessage.hasEmoteeventmessage()) {
|
||||
const emoteMessage = subMessage.getEmoteeventmessage() as EmoteEventMessage;
|
||||
emoteEventStream.fire(emoteMessage.getActoruserid(), emoteMessage.getEmote());
|
||||
} else if (subMessage.hasPlayerdetailsupdatedmessage()) {
|
||||
event = EventMessage.USER_DETAILS_UPDATED;
|
||||
payload = subMessage.getPlayerdetailsupdatedmessage();
|
||||
} else if (subMessage.hasErrormessage()) {
|
||||
const errorMessage = subMessage.getErrormessage() as ErrorMessage;
|
||||
console.error("An error occurred server side: " + errorMessage.getMessage());
|
||||
|
@ -276,7 +281,7 @@ export class RoomConnection implements RoomConnection {
|
|||
}
|
||||
}
|
||||
|
||||
public emitPlayerDetailsMessage(userName: string, characterLayersSelected: BodyResourceDescriptionInterface[]) {
|
||||
/*public emitPlayerDetailsMessage(userName: string, characterLayersSelected: BodyResourceDescriptionInterface[]) {
|
||||
const message = new SetPlayerDetailsMessage();
|
||||
message.setName(userName);
|
||||
message.setCharacterlayersList(characterLayersSelected.map((characterLayer) => characterLayer.name));
|
||||
|
@ -284,6 +289,20 @@ export class RoomConnection implements RoomConnection {
|
|||
const clientToServerMessage = new ClientToServerMessage();
|
||||
clientToServerMessage.setSetplayerdetailsmessage(message);
|
||||
|
||||
this.socket.send(clientToServerMessage.serializeBinary().buffer);
|
||||
}*/
|
||||
|
||||
public emitPlayerOutlineColor(color: number | null) {
|
||||
const message = new SetPlayerDetailsMessage();
|
||||
if (color === null) {
|
||||
message.setRemoveoutlinecolor(true);
|
||||
} else {
|
||||
message.setOutlinecolor(color);
|
||||
}
|
||||
|
||||
const clientToServerMessage = new ClientToServerMessage();
|
||||
clientToServerMessage.setSetplayerdetailsmessage(message);
|
||||
|
||||
this.socket.send(clientToServerMessage.serializeBinary().buffer);
|
||||
}
|
||||
|
||||
|
@ -404,6 +423,7 @@ export class RoomConnection implements RoomConnection {
|
|||
position: ProtobufClientUtils.toPointInterface(position),
|
||||
companion: companion ? companion.getName() : null,
|
||||
userUuid: message.getUseruuid(),
|
||||
outlineColor: message.getHasoutline() ? message.getOutlinecolor() : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -596,6 +616,20 @@ export class RoomConnection implements RoomConnection {
|
|||
});
|
||||
}
|
||||
|
||||
onPlayerDetailsUpdated(callback: (message: PlayerDetailsUpdatedMessageInterface) => void): void {
|
||||
this.onMessage(EventMessage.USER_DETAILS_UPDATED, (message: PlayerDetailsUpdatedMessage) => {
|
||||
const details = message.getDetails();
|
||||
if (details === undefined) {
|
||||
throw new Error("Malformed message. Missing details in PlayerDetailsUpdatedMessage");
|
||||
}
|
||||
callback({
|
||||
userId: message.getUserid(),
|
||||
outlineColor: details.getOutlinecolor(),
|
||||
removeOutlineColor: details.getRemoveoutlinecolor(),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public uploadAudio(file: FormData) {
|
||||
return Axios.post(`${UPLOADER_URL}/upload-audio-message`, file)
|
||||
.then((res: { data: {} }) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue