Merge branch 'develop' of github.com:thecodingmachine/workadventure into scripting_api_room_metadata
This commit is contained in:
commit
19bd1045e1
@ -15,7 +15,7 @@ export class DebugController {
|
|||||||
const query = parse(req.getQuery());
|
const query = parse(req.getQuery());
|
||||||
|
|
||||||
if (query.token !== ADMIN_API_TOKEN) {
|
if (query.token !== ADMIN_API_TOKEN) {
|
||||||
return res.status(401).send("Invalid token sent!");
|
return res.writeStatus("401 Unauthorized").end("Invalid token sent!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
@ -29,7 +29,8 @@ import {
|
|||||||
EmoteEventMessage,
|
EmoteEventMessage,
|
||||||
BanUserMessage,
|
BanUserMessage,
|
||||||
RefreshRoomMessage,
|
RefreshRoomMessage,
|
||||||
EmotePromptMessage, VariableMessage,
|
EmotePromptMessage,
|
||||||
|
VariableMessage,
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
import { User, UserSocket } from "../Model/User";
|
import { User, UserSocket } from "../Model/User";
|
||||||
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
||||||
@ -447,8 +448,6 @@ export class SocketManager {
|
|||||||
// Let's send 2 messages: one to the user joining the group and one to the other user
|
// Let's send 2 messages: one to the user joining the group and one to the other user
|
||||||
const webrtcStartMessage1 = new WebRtcStartMessage();
|
const webrtcStartMessage1 = new WebRtcStartMessage();
|
||||||
webrtcStartMessage1.setUserid(otherUser.id);
|
webrtcStartMessage1.setUserid(otherUser.id);
|
||||||
webrtcStartMessage1.setUseruuid(otherUser.uuid);
|
|
||||||
webrtcStartMessage1.setName(otherUser.name);
|
|
||||||
webrtcStartMessage1.setInitiator(true);
|
webrtcStartMessage1.setInitiator(true);
|
||||||
if (TURN_STATIC_AUTH_SECRET !== "") {
|
if (TURN_STATIC_AUTH_SECRET !== "") {
|
||||||
const { username, password } = this.getTURNCredentials("" + otherUser.id, TURN_STATIC_AUTH_SECRET);
|
const { username, password } = this.getTURNCredentials("" + otherUser.id, TURN_STATIC_AUTH_SECRET);
|
||||||
@ -466,8 +465,6 @@ export class SocketManager {
|
|||||||
|
|
||||||
const webrtcStartMessage2 = new WebRtcStartMessage();
|
const webrtcStartMessage2 = new WebRtcStartMessage();
|
||||||
webrtcStartMessage2.setUserid(user.id);
|
webrtcStartMessage2.setUserid(user.id);
|
||||||
webrtcStartMessage2.setUseruuid(user.uuid);
|
|
||||||
webrtcStartMessage2.setName(user.name);
|
|
||||||
webrtcStartMessage2.setInitiator(false);
|
webrtcStartMessage2.setInitiator(false);
|
||||||
if (TURN_STATIC_AUTH_SECRET !== "") {
|
if (TURN_STATIC_AUTH_SECRET !== "") {
|
||||||
const { username, password } = this.getTURNCredentials("" + user.id, TURN_STATIC_AUTH_SECRET);
|
const { username, password } = this.getTURNCredentials("" + user.id, TURN_STATIC_AUTH_SECRET);
|
||||||
|
@ -31,7 +31,8 @@ import {
|
|||||||
EmoteEventMessage,
|
EmoteEventMessage,
|
||||||
EmotePromptMessage,
|
EmotePromptMessage,
|
||||||
SendUserMessage,
|
SendUserMessage,
|
||||||
BanUserMessage, VariableMessage,
|
BanUserMessage,
|
||||||
|
VariableMessage,
|
||||||
} from "../Messages/generated/messages_pb";
|
} from "../Messages/generated/messages_pb";
|
||||||
|
|
||||||
import type { UserSimplePeerInterface } from "../WebRtc/SimplePeer";
|
import type { UserSimplePeerInterface } from "../WebRtc/SimplePeer";
|
||||||
@ -466,7 +467,6 @@ export class RoomConnection implements RoomConnection {
|
|||||||
this.onMessage(EventMessage.WEBRTC_START, (message: WebRtcStartMessage) => {
|
this.onMessage(EventMessage.WEBRTC_START, (message: WebRtcStartMessage) => {
|
||||||
callback({
|
callback({
|
||||||
userId: message.getUserid(),
|
userId: message.getUserid(),
|
||||||
name: message.getName(),
|
|
||||||
initiator: message.getInitiator(),
|
initiator: message.getInitiator(),
|
||||||
webRtcUser: message.getWebrtcusername() ?? undefined,
|
webRtcUser: message.getWebrtcusername() ?? undefined,
|
||||||
webRtcPassword: message.getWebrtcpassword() ?? undefined,
|
webRtcPassword: message.getWebrtcpassword() ?? undefined,
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
import type {PointInterface} from "../../Connexion/ConnexionModels";
|
import type { PointInterface } from "../../Connexion/ConnexionModels";
|
||||||
import type {BodyResourceDescriptionInterface} from "../Entity/PlayerTextures";
|
import type { PlayerInterface } from "./PlayerInterface";
|
||||||
|
|
||||||
export interface AddPlayerInterface {
|
export interface AddPlayerInterface extends PlayerInterface {
|
||||||
userId: number;
|
|
||||||
name: string;
|
|
||||||
characterLayers: BodyResourceDescriptionInterface[];
|
|
||||||
position: PointInterface;
|
position: PointInterface;
|
||||||
visitCardUrl: string|null;
|
|
||||||
companion: string|null;
|
|
||||||
}
|
}
|
||||||
|
@ -47,13 +47,7 @@ import { RemotePlayer } from "../Entity/RemotePlayer";
|
|||||||
import type { ActionableItem } from "../Items/ActionableItem";
|
import type { ActionableItem } from "../Items/ActionableItem";
|
||||||
import type { ItemFactoryInterface } from "../Items/ItemFactoryInterface";
|
import type { ItemFactoryInterface } from "../Items/ItemFactoryInterface";
|
||||||
import { SelectCharacterScene, SelectCharacterSceneName } from "../Login/SelectCharacterScene";
|
import { SelectCharacterScene, SelectCharacterSceneName } from "../Login/SelectCharacterScene";
|
||||||
import type {
|
import type { ITiledMap, ITiledMapLayer, ITiledMapProperty, ITiledMapObject, ITiledTileSet } from "../Map/ITiledMap";
|
||||||
ITiledMap,
|
|
||||||
ITiledMapLayer,
|
|
||||||
ITiledMapProperty,
|
|
||||||
ITiledMapObject,
|
|
||||||
ITiledTileSet,
|
|
||||||
} from "../Map/ITiledMap";
|
|
||||||
import { MenuScene, MenuSceneName } from "../Menu/MenuScene";
|
import { MenuScene, MenuSceneName } from "../Menu/MenuScene";
|
||||||
import { PlayerAnimationDirections } from "../Player/Animation";
|
import { PlayerAnimationDirections } from "../Player/Animation";
|
||||||
import { hasMovedEventName, Player, requestEmoteEventName } from "../Player/Player";
|
import { hasMovedEventName, Player, requestEmoteEventName } from "../Player/Player";
|
||||||
@ -92,6 +86,7 @@ import { peerStore, screenSharingPeerStore } from "../../Stores/PeerStore";
|
|||||||
import { videoFocusStore } from "../../Stores/VideoFocusStore";
|
import { videoFocusStore } from "../../Stores/VideoFocusStore";
|
||||||
import { biggestAvailableAreaStore } from "../../Stores/BiggestAvailableAreaStore";
|
import { biggestAvailableAreaStore } from "../../Stores/BiggestAvailableAreaStore";
|
||||||
import { SharedVariablesManager } from "./SharedVariablesManager";
|
import { SharedVariablesManager } from "./SharedVariablesManager";
|
||||||
|
import { playersStore } from "../../Stores/PlayersStore";
|
||||||
|
|
||||||
export interface GameSceneInitInterface {
|
export interface GameSceneInitInterface {
|
||||||
initPosition: PointInterface | null;
|
initPosition: PointInterface | null;
|
||||||
@ -599,6 +594,8 @@ export class GameScene extends DirtyScene {
|
|||||||
.then((onConnect: OnConnectInterface) => {
|
.then((onConnect: OnConnectInterface) => {
|
||||||
this.connection = onConnect.connection;
|
this.connection = onConnect.connection;
|
||||||
|
|
||||||
|
playersStore.connectToRoomConnection(this.connection);
|
||||||
|
|
||||||
this.connection.onUserJoins((message: MessageUserJoined) => {
|
this.connection.onUserJoins((message: MessageUserJoined) => {
|
||||||
const userMessage: AddPlayerInterface = {
|
const userMessage: AddPlayerInterface = {
|
||||||
userId: message.userId,
|
userId: message.userId,
|
||||||
@ -1043,13 +1040,13 @@ ${escapedMessage}
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
iframeListener.registerAnswerer('getMapData', () => {
|
iframeListener.registerAnswerer("getMapData", () => {
|
||||||
return {
|
return {
|
||||||
data: this.gameMap.getMap()
|
data: this.gameMap.getMap(),
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
iframeListener.registerAnswerer('getState', async () => {
|
iframeListener.registerAnswerer("getState", async () => {
|
||||||
// The sharedVariablesManager is not instantiated before the connection is established. So we need to wait
|
// The sharedVariablesManager is not instantiated before the connection is established. So we need to wait
|
||||||
// for the connection to send back the answer.
|
// for the connection to send back the answer.
|
||||||
await this.connectionAnswerPromise;
|
await this.connectionAnswerPromise;
|
||||||
@ -1156,7 +1153,7 @@ ${escapedMessage}
|
|||||||
this.emoteManager.destroy();
|
this.emoteManager.destroy();
|
||||||
this.peerStoreUnsubscribe();
|
this.peerStoreUnsubscribe();
|
||||||
this.biggestAvailableAreaStoreUnsubscribe();
|
this.biggestAvailableAreaStoreUnsubscribe();
|
||||||
iframeListener.unregisterAnswerer('getState');
|
iframeListener.unregisterAnswerer("getState");
|
||||||
this.sharedVariablesManager?.close();
|
this.sharedVariablesManager?.close();
|
||||||
|
|
||||||
mediaManager.hideGameOverlay();
|
mediaManager.hideGameOverlay();
|
||||||
|
9
front/src/Phaser/Game/PlayerInterface.ts
Normal file
9
front/src/Phaser/Game/PlayerInterface.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import type { BodyResourceDescriptionInterface } from "../Entity/PlayerTextures";
|
||||||
|
|
||||||
|
export interface PlayerInterface {
|
||||||
|
userId: number;
|
||||||
|
name: string;
|
||||||
|
characterLayers: BodyResourceDescriptionInterface[];
|
||||||
|
visitCardUrl: string | null;
|
||||||
|
companion: string | null;
|
||||||
|
}
|
43
front/src/Stores/PlayersStore.ts
Normal file
43
front/src/Stores/PlayersStore.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { writable } from "svelte/store";
|
||||||
|
import type { PlayerInterface } from "../Phaser/Game/PlayerInterface";
|
||||||
|
import type { RoomConnection } from "../Connexion/RoomConnection";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A store that contains the list of players currently known.
|
||||||
|
*/
|
||||||
|
function createPlayersStore() {
|
||||||
|
let players = new Map<number, PlayerInterface>();
|
||||||
|
|
||||||
|
const { subscribe, set, update } = writable(players);
|
||||||
|
|
||||||
|
return {
|
||||||
|
subscribe,
|
||||||
|
connectToRoomConnection: (roomConnection: RoomConnection) => {
|
||||||
|
players = new Map<number, PlayerInterface>();
|
||||||
|
set(players);
|
||||||
|
roomConnection.onUserJoins((message) => {
|
||||||
|
update((users) => {
|
||||||
|
users.set(message.userId, {
|
||||||
|
userId: message.userId,
|
||||||
|
name: message.name,
|
||||||
|
characterLayers: message.characterLayers,
|
||||||
|
visitCardUrl: message.visitCardUrl,
|
||||||
|
companion: message.companion,
|
||||||
|
});
|
||||||
|
return users;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
roomConnection.onUserLeft((userId) => {
|
||||||
|
update((users) => {
|
||||||
|
users.delete(userId);
|
||||||
|
return users;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getPlayerById(userId: number): PlayerInterface | undefined {
|
||||||
|
return players.get(userId);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const playersStore = createPlayersStore();
|
@ -11,10 +11,10 @@ import { get } from "svelte/store";
|
|||||||
import { localStreamStore, LocalStreamStoreValue, obtainedMediaConstraintStore } from "../Stores/MediaStore";
|
import { localStreamStore, LocalStreamStoreValue, obtainedMediaConstraintStore } from "../Stores/MediaStore";
|
||||||
import { screenSharingLocalStreamStore } from "../Stores/ScreenSharingStore";
|
import { screenSharingLocalStreamStore } from "../Stores/ScreenSharingStore";
|
||||||
import { discussionManager } from "./DiscussionManager";
|
import { discussionManager } from "./DiscussionManager";
|
||||||
|
import { playersStore } from "../Stores/PlayersStore";
|
||||||
|
|
||||||
export interface UserSimplePeerInterface {
|
export interface UserSimplePeerInterface {
|
||||||
userId: number;
|
userId: number;
|
||||||
name?: string;
|
|
||||||
initiator?: boolean;
|
initiator?: boolean;
|
||||||
webRtcUser?: string | undefined;
|
webRtcUser?: string | undefined;
|
||||||
webRtcPassword?: string | undefined;
|
webRtcPassword?: string | undefined;
|
||||||
@ -153,10 +153,7 @@ export class SimplePeer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = user.name;
|
const name = this.getName(user.userId);
|
||||||
if (!name) {
|
|
||||||
name = this.getName(user.userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
discussionManager.removeParticipant(user.userId);
|
discussionManager.removeParticipant(user.userId);
|
||||||
|
|
||||||
@ -191,7 +188,7 @@ export class SimplePeer {
|
|||||||
|
|
||||||
//Create a notification for first user in circle discussion
|
//Create a notification for first user in circle discussion
|
||||||
if (this.PeerConnectionArray.size === 0) {
|
if (this.PeerConnectionArray.size === 0) {
|
||||||
mediaManager.createNotification(user.name ?? "");
|
mediaManager.createNotification(name);
|
||||||
}
|
}
|
||||||
this.PeerConnectionArray.set(user.userId, peer);
|
this.PeerConnectionArray.set(user.userId, peer);
|
||||||
|
|
||||||
@ -202,12 +199,7 @@ export class SimplePeer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private getName(userId: number): string {
|
private getName(userId: number): string {
|
||||||
const userSearch = this.Users.find((userSearch: UserSimplePeerInterface) => userSearch.userId === userId);
|
return playersStore.getPlayerById(userId)?.name || "";
|
||||||
if (userSearch) {
|
|
||||||
return userSearch.name || "";
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,7 +191,6 @@ message RoomJoinedMessage {
|
|||||||
|
|
||||||
message WebRtcStartMessage {
|
message WebRtcStartMessage {
|
||||||
int32 userId = 1;
|
int32 userId = 1;
|
||||||
string name = 2;
|
|
||||||
bool initiator = 3;
|
bool initiator = 3;
|
||||||
string webrtcUserName = 4;
|
string webrtcUserName = 4;
|
||||||
string webrtcPassword = 5;
|
string webrtcPassword = 5;
|
||||||
|
@ -16,7 +16,7 @@ export class DebugController {
|
|||||||
const query = parse(req.getQuery());
|
const query = parse(req.getQuery());
|
||||||
|
|
||||||
if (query.token !== ADMIN_API_TOKEN) {
|
if (query.token !== ADMIN_API_TOKEN) {
|
||||||
return res.status(401).send("Invalid token sent!");
|
return res.writeStatus("401 Unauthorized").end("Invalid token sent!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
Loading…
Reference in New Issue
Block a user