From 876ddc87d22d9f716eefded374e872b8183f265c Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Mon, 7 Feb 2022 19:26:34 +0100 Subject: [PATCH 01/33] =?UTF-8?q?Change=20acc=C3=A8s=20token=20with=20quer?= =?UTF-8?q?y=20privateAccessToken=20in=20the=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 40 ++++++++++++++++++++++-- front/src/Url/UrlManager.ts | 23 ++++++++++++-- 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 05d0255d..6f1984ae 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -2,7 +2,7 @@ import Axios from "axios"; import { PUSHER_URL } from "../Enum/EnvironmentVariable"; import { RoomConnection } from "./RoomConnection"; import type { OnConnectInterface, PositionInterface, ViewportInterface } from "./ConnexionModels"; -import { GameConnexionTypes, urlManager } from "../Url/UrlManager"; +import { GameConnexionTypes, queryPrivateAccessToken, urlManager } from "../Url/UrlManager"; import { localUserStore } from "./LocalUserStore"; import { CharacterTexture, LocalUser } from "./LocalUser"; import { Room } from "./Room"; @@ -124,8 +124,42 @@ class ConnectionManager { return Promise.reject(new Error("You will be redirect on login page")); } urlManager.pushRoomIdToUrl(this._currentRoom); - } else if (connexionType === GameConnexionTypes.register) { - //@deprecated + } else if (connexionType === GameConnexionTypes.privateAccessToken) { + const organizationMemberToken = urlManager.getPrivateAccessToken; + + //clear queryPrivateAccessToken query in window location + urlParams.delete(queryPrivateAccessToken); + + 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); + localUserStore.setAuthToken(this.authToken); + analyticsClient.loggedWithToken(); + + const roomUrl = data.roomUrl; + + const query = urlParams.toString(); + this._currentRoom = await Room.createRoom( + new URL( + window.location.protocol + + "//" + + window.location.host + + roomUrl + + (query ? "?" + query : "") + //use urlParams because the token param must be deleted + window.location.hash + ) + ); + urlManager.pushRoomIdToUrl(this._currentRoom); + } + //@deprecated + else if (connexionType === GameConnexionTypes.register) { const organizationMemberToken = urlManager.getOrganizationToken(); const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then( (res) => res.data diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index cb0e1ed0..b8a967c6 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -3,13 +3,16 @@ import { localUserStore } from "../Connexion/LocalUserStore"; export enum GameConnexionTypes { room = 1, - register, + register /*@deprecated*/, empty, unknown, jwt, login, + privateAccessToken, } +export const queryPrivateAccessToken = "privateAccessToken"; + //this class is responsible with analysing and editing the game's url class UrlManager { public getGameConnexionType(): GameConnexionTypes { @@ -19,8 +22,13 @@ class UrlManager { } else if (url === "/jwt") { return GameConnexionTypes.jwt; } else if (url.includes("_/") || url.includes("*/") || url.includes("@/")) { + if (window.location.search.includes(queryPrivateAccessToken)) { + return GameConnexionTypes.privateAccessToken; + } return GameConnexionTypes.room; - } else if (url.includes("register/")) { + } + //@deprecated register url will be replace by "?privateAccessToken=" + else if (url.includes("register/")) { return GameConnexionTypes.register; } else if (url === "/") { return GameConnexionTypes.empty; @@ -29,6 +37,17 @@ class UrlManager { } } + /** + * @return string + */ + get getPrivateAccessToken(): string | null { + const urlParams = new URLSearchParams(window.location.search.toString()); + return urlParams.get(queryPrivateAccessToken); + } + + /** + * @deprecated + */ public getOrganizationToken(): string | null { const match = /\/register\/(.+)/.exec(window.location.pathname.toString()); return match ? match[1] : null; From 64ba7575a09d874b6d53edc523b1a8c99c6c0c79 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 8 Feb 2022 18:47:11 +0100 Subject: [PATCH 02/33] Add play uri param Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 9 ++++++--- pusher/src/Controller/AuthenticateController.ts | 3 ++- pusher/src/Services/AdminApi.ts | 12 +++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 6f1984ae..344f9152 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -130,9 +130,12 @@ class ConnectionManager { //clear queryPrivateAccessToken query in window location urlParams.delete(queryPrivateAccessToken); - const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then( - (res) => res.data - ); + //create play uri parameter + const playUri = window.location.protocol + "//" + window.location.host; + const data = await Axios.post(`${PUSHER_URL}/register`, { + organizationMemberToken, + playUri, + }).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."); diff --git a/pusher/src/Controller/AuthenticateController.ts b/pusher/src/Controller/AuthenticateController.ts index fe80eafa..046de8fe 100644 --- a/pusher/src/Controller/AuthenticateController.ts +++ b/pusher/src/Controller/AuthenticateController.ts @@ -170,10 +170,11 @@ export class AuthenticateController extends BaseController { //todo: what to do if the organizationMemberToken is already used? const organizationMemberToken: string | null = param.organizationMemberToken; + const playUri: string | null = param.playUri; try { if (typeof organizationMemberToken != "string") throw new Error("No organization token"); - const data = await adminApi.fetchMemberDataByToken(organizationMemberToken); + const data = await adminApi.fetchMemberDataByToken(organizationMemberToken, playUri); const userUuid = data.userUuid; const email = data.email; const roomUrl = data.roomUrl; diff --git a/pusher/src/Services/AdminApi.ts b/pusher/src/Services/AdminApi.ts index c72a6ba8..6fe1d258 100644 --- a/pusher/src/Services/AdminApi.ts +++ b/pusher/src/Services/AdminApi.ts @@ -47,25 +47,31 @@ class AdminApi { async fetchMemberDataByUuid( userIdentifier: string | null, - roomId: string, + playUri: string, ipAddress: string ): Promise { if (!ADMIN_API_URL) { return Promise.reject(new Error("No admin backoffice set!")); } const res = await Axios.get(ADMIN_API_URL + "/api/room/access", { - params: { userIdentifier, roomId, ipAddress }, + params: { + userIdentifier, + roomId: playUri /* @deprecated */, + playUri, + ipAddress, + }, headers: { Authorization: `${ADMIN_API_TOKEN}` }, }); return res.data; } - async fetchMemberDataByToken(organizationMemberToken: string): Promise { + async fetchMemberDataByToken(organizationMemberToken: string, playUri: string | null): Promise { if (!ADMIN_API_URL) { return Promise.reject(new Error("No admin backoffice set!")); } //todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case. const res = await Axios.get(ADMIN_API_URL + "/api/login-url/" + organizationMemberToken, { + params: { playUri }, headers: { Authorization: `${ADMIN_API_TOKEN}` }, }); if (!isAdminApiData(res.data)) { From cfbf9dca232fe91543a7f1bf307aad1667cfe668 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 8 Feb 2022 20:31:08 +0100 Subject: [PATCH 03/33] PlayUri parameter Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 344f9152..b5a25fbb 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -131,7 +131,7 @@ class ConnectionManager { urlParams.delete(queryPrivateAccessToken); //create play uri parameter - const playUri = window.location.protocol + "//" + window.location.host; + const playUri = window.location.protocol + "//" + window.location.host + window.location.pathname; const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken, playUri, From 8d8857011ea9fae0933af2802ef7f040db987843 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Wed, 23 Feb 2022 14:40:19 +0100 Subject: [PATCH 04/33] removed unused imports --- front/src/Connexion/RoomConnection.ts | 17 +---------------- front/src/Phaser/Game/GameScene.ts | 1 + 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 4e2f8397..584a1a51 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -5,15 +5,11 @@ import type { UserSimplePeerInterface } from "../WebRtc/SimplePeer"; import { ProtobufClientUtils } from "../Network/ProtobufClientUtils"; import type { GroupCreatedUpdatedMessageInterface, - ItemEventMessageInterface, MessageUserJoined, - OnConnectInterface, - PlayerDetailsUpdatedMessageInterface, PlayGlobalMessageInterface, PositionInterface, RoomJoinedMessageInterface, ViewportInterface, - WebRtcDisconnectMessageInterface, WebRtcSignalReceivedMessageInterface, } from "./ConnexionModels"; import type { BodyResourceDescriptionInterface } from "../Phaser/Entity/PlayerTextures"; @@ -21,31 +17,22 @@ import { adminMessagesService } from "./AdminMessagesService"; import { connectionManager } from "./ConnectionManager"; import { get } from "svelte/store"; import { warningContainerStore } from "../Stores/MenuStore"; -import { followStateStore, followRoleStore, followUsersStore } from "../Stores/FollowStore"; +import { followRoleStore, followUsersStore } from "../Stores/FollowStore"; import { localUserStore } from "./LocalUserStore"; import { - RefreshRoomMessage, ServerToClientMessage as ServerToClientMessageTsProto, TokenExpiredMessage, WorldConnexionMessage, - WorldFullMessage, ErrorMessage as ErrorMessageTsProto, UserMovedMessage as UserMovedMessageTsProto, GroupUpdateMessage as GroupUpdateMessageTsProto, GroupDeleteMessage as GroupDeleteMessageTsProto, UserJoinedMessage as UserJoinedMessageTsProto, UserLeftMessage as UserLeftMessageTsProto, - ItemEventMessage as ItemEventMessageTsProto, EmoteEventMessage as EmoteEventMessageTsProto, - VariableMessage as VariableMessageTsProto, PlayerDetailsUpdatedMessage as PlayerDetailsUpdatedMessageTsProto, - WorldFullWarningMessage, WebRtcDisconnectMessage as WebRtcDisconnectMessageTsProto, - PlayGlobalMessage as PlayGlobalMessageTsProto, - StopGlobalMessage as StopGlobalMessageTsProto, SendJitsiJwtMessage as SendJitsiJwtMessageTsProto, - SendUserMessage as SendUserMessageTsProto, - BanUserMessage as BanUserMessageTsProto, ClientToServerMessage as ClientToServerMessageTsProto, PositionMessage as PositionMessageTsProto, ViewportMessage as ViewportMessageTsProto, @@ -54,8 +41,6 @@ import { PingMessage as PingMessageTsProto, } from "../Messages/ts-proto-generated/messages"; import { Subject } from "rxjs"; -import { OpenPopupEvent } from "../Api/Events/OpenPopupEvent"; -import { match } from "assert"; const manualPingDelay = 20000; diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 0a44cea3..274ae573 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1976,6 +1976,7 @@ ${escapedMessage} } private doShareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface) { + console.log(groupPositionMessage); //delete previous group this.doDeleteGroup(groupPositionMessage.groupId); From 724dbc8efac7a8eea78260e7787c5d8f4be9ab81 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Mon, 28 Feb 2022 13:47:08 +0100 Subject: [PATCH 05/33] send group userIds to players --- back/src/Model/Group.ts | 2 +- back/src/Services/SocketManager.ts | 24 ++++++++++++++++++++++-- front/src/Connexion/ConnexionModels.ts | 5 +++++ front/src/Connexion/RoomConnection.ts | 10 ++++++++++ front/src/Phaser/Game/GameScene.ts | 1 - messages/protos/messages.proto | 6 ++++++ 6 files changed, 44 insertions(+), 4 deletions(-) diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index c14d509f..65e15c40 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -147,9 +147,9 @@ export class Group implements Movable { join(user: User): void { // Broadcast on the right event - this.connectCallback(user, this); this.users.add(user); user.group = this; + this.connectCallback(user, this); } leave(user: User): void { diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index 9233811b..c396893d 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -38,6 +38,7 @@ import { SubToPusherRoomMessage, SetPlayerDetailsMessage, PlayerDetailsUpdatedMessage, + GroupUsersUpdateMessage, } from "../Messages/generated/messages_pb"; import { User, UserSocket } from "../Model/User"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; @@ -265,8 +266,14 @@ export class SocketManager { if (roomPromise === undefined) { roomPromise = GameRoom.create( roomId, - (user: User, group: Group) => this.joinWebRtcRoom(user, group), - (user: User, group: Group) => this.disConnectedUser(user, group), + (user: User, group: Group) => { + this.joinWebRtcRoom(user, group); + this.sendGroupUsersUpdateToGroupMembers(group); + }, + (user: User, group: Group) => { + this.disConnectedUser(user, group); + this.sendGroupUsersUpdateToGroupMembers(group); + }, MINIMUM_DISTANCE, GROUP_RADIUS, (thing: Movable, fromZone: Zone | null, listener: ZoneSocket) => @@ -438,6 +445,19 @@ export class SocketManager { return undefined; } + private sendGroupUsersUpdateToGroupMembers(group: Group) { + const groupUserUpdateMessage = new GroupUsersUpdateMessage(); + groupUserUpdateMessage.setGroupid(group.getId()); + groupUserUpdateMessage.setUseridsList(group.getUsers().map((user) => user.id)); + + const clientMessage = new ServerToClientMessage(); + clientMessage.setGroupusersupdatemessage(groupUserUpdateMessage); + + group.getUsers().forEach((currentUser: User) => { + currentUser.socket.write(clientMessage); + }); + } + private joinWebRtcRoom(user: User, group: Group) { for (const otherUser of group.getUsers()) { if (user === otherUser) { diff --git a/front/src/Connexion/ConnexionModels.ts b/front/src/Connexion/ConnexionModels.ts index bf834a02..3d8893a2 100644 --- a/front/src/Connexion/ConnexionModels.ts +++ b/front/src/Connexion/ConnexionModels.ts @@ -47,6 +47,11 @@ export interface GroupCreatedUpdatedMessageInterface { groupSize: number; } +export interface GroupUsersUpdateMessageInterface { + groupId: number; + userIds: number[]; +} + export interface WebRtcDisconnectMessageInterface { userId: number; } diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 584a1a51..95c91cd5 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -5,6 +5,7 @@ import type { UserSimplePeerInterface } from "../WebRtc/SimplePeer"; import { ProtobufClientUtils } from "../Network/ProtobufClientUtils"; import type { GroupCreatedUpdatedMessageInterface, + GroupUsersUpdateMessageInterface, MessageUserJoined, PlayGlobalMessageInterface, PositionInterface, @@ -97,6 +98,9 @@ export class RoomConnection implements RoomConnection { private readonly _groupUpdateMessageStream = new Subject(); public readonly groupUpdateMessageStream = this._groupUpdateMessageStream.asObservable(); + private readonly _groupUsersUpdateMessageStream = new Subject(); + public readonly groupUsersUpdateMessageStream = this._groupUsersUpdateMessageStream.asObservable(); + private readonly _groupDeleteMessageStream = new Subject(); public readonly groupDeleteMessageStream = this._groupDeleteMessageStream.asObservable(); @@ -398,6 +402,12 @@ export class RoomConnection implements RoomConnection { this._sendJitsiJwtMessageStream.next(message.sendJitsiJwtMessage); break; } + case "groupUsersUpdateMessage": { + console.log("GOT GROUP USERS UPDATE MESSAGE"); + console.log(message.groupUsersUpdateMessage); + this._groupUsersUpdateMessageStream.next(message.groupUsersUpdateMessage); + break; + } case "sendUserMessage": { adminMessagesService.onSendusermessage(message.sendUserMessage); break; diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 274ae573..0a44cea3 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1976,7 +1976,6 @@ ${escapedMessage} } private doShareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface) { - console.log(groupPositionMessage); //delete previous group this.doDeleteGroup(groupPositionMessage.groupId); diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 8ac7bbf0..5c9c95b7 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -215,6 +215,11 @@ message ItemStateMessage { string stateJson = 2; } +message GroupUsersUpdateMessage { + int32 groupId = 1; + repeated int32 userIds = 2; +} + message RoomJoinedMessage { //repeated UserJoinedMessage user = 1; //repeated GroupUpdateMessage group = 2; @@ -310,6 +315,7 @@ message ServerToClientMessage { FollowRequestMessage followRequestMessage = 21; FollowConfirmationMessage followConfirmationMessage = 22; FollowAbortMessage followAbortMessage = 23; + GroupUsersUpdateMessage groupUsersUpdateMessage = 24; } } From d43c8d181af71542abe1c268de8a0bcaf4aaaca6 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Tue, 1 Mar 2022 11:36:45 +0100 Subject: [PATCH 06/33] sending info about group lock state. wip --- back/src/Model/GameRoom.ts | 2 +- back/src/Model/Group.ts | 9 +++++++++ back/src/RoomManager.ts | 8 ++++++++ back/src/Services/SocketManager.ts | 7 +++++++ front/src/Connexion/ConnexionModels.ts | 1 + front/src/Connexion/RoomConnection.ts | 15 +++++++++++++++ front/src/Phaser/Game/GameScene.ts | 20 +++++++++++++++++++- messages/protos/messages.proto | 11 +++++++++++ pusher/src/Controller/IoSocketController.ts | 3 +++ pusher/src/Model/Zone.ts | 15 +++++++++++++-- pusher/src/Services/SocketManager.ts | 7 +++++++ 11 files changed, 94 insertions(+), 4 deletions(-) diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index 7d7b24a5..b55c6079 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -418,7 +418,7 @@ export class GameRoom { }); this.groups.forEach((group: Group) => { - if (group.isFull()) { + if (group.isFull() || group.isLocked()) { return; } const distance = GameRoom.computeDistanceBetweenPositions(user.getPosition(), group.getPosition()); diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index 65e15c40..a960e7b3 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -14,6 +14,7 @@ export class Group implements Movable { private x!: number; private y!: number; private wasDestroyed: boolean = false; + private locked: boolean = false; private roomId: string; private currentZone: Zone | null = null; /** @@ -141,6 +142,10 @@ export class Group implements Movable { return this.users.size >= MAX_PER_GROUP; } + isLocked(): boolean { + return this.locked; + } + isEmpty(): boolean { return this.users.size <= 1; } @@ -167,6 +172,10 @@ export class Group implements Movable { this.disconnectCallback(user, this); } + lock(lock: boolean = true): void { + this.locked = lock; + } + /** * Let's kick everybody out. * Usually used when there is only one user left. diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index d375fbd8..b5e27982 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -29,6 +29,7 @@ import { WebRtcSignalToServerMessage, WorldFullWarningToRoomMessage, ZoneMessage, + LockGroupMessage, } from "./Messages/generated/messages_pb"; import { sendUnaryData, ServerDuplexStream, ServerUnaryCall, ServerWritableStream } from "grpc"; import { socketManager } from "./Services/SocketManager"; @@ -135,6 +136,11 @@ const roomManager: IRoomManagerServer = { user, message.getFollowabortmessage() as FollowAbortMessage ); + } else if (message.hasLockgroupmessage()) { + socketManager.handleLockGroupMessage( + user, + message.getLockgroupmessage() as LockGroupMessage + ); } else if (message.hasSendusermessage()) { const sendUserMessage = message.getSendusermessage(); socketManager.handleSendUserMessage(user, sendUserMessage as SendUserMessage); @@ -148,6 +154,8 @@ const roomManager: IRoomManagerServer = { user, setPlayerDetailsMessage as SetPlayerDetailsMessage ); + } else if (message.hasLockgroupmessage()) { + console.log("===== GOT LOCK GROUP MESSAGE FROM CLIENT ====="); } else { throw new Error("Unhandled message type"); } diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index c396893d..af0ec6cf 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -39,6 +39,7 @@ import { SetPlayerDetailsMessage, PlayerDetailsUpdatedMessage, GroupUsersUpdateMessage, + LockGroupMessage, } from "../Messages/generated/messages_pb"; import { User, UserSocket } from "../Model/User"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; @@ -404,6 +405,7 @@ export class SocketManager { groupUpdateMessage.setPosition(pointMessage); groupUpdateMessage.setGroupsize(group.getSize); groupUpdateMessage.setFromzone(this.toProtoZone(fromZone)); + groupUpdateMessage.setLocked(group.isLocked()); const subMessage = new SubToPusherMessage(); subMessage.setGroupupdatezonemessage(groupUpdateMessage); @@ -889,6 +891,11 @@ export class SocketManager { leader?.delFollower(user); } } + + handleLockGroupMessage(user: User, message: LockGroupMessage) { + console.log(`lock group: ${message.getLock()}`); + user.group?.lock(message.getLock()); + } } export const socketManager = new SocketManager(); diff --git a/front/src/Connexion/ConnexionModels.ts b/front/src/Connexion/ConnexionModels.ts index 3d8893a2..04282abc 100644 --- a/front/src/Connexion/ConnexionModels.ts +++ b/front/src/Connexion/ConnexionModels.ts @@ -45,6 +45,7 @@ export interface GroupCreatedUpdatedMessageInterface { position: PositionInterface; groupId: number; groupSize: number; + locked: boolean; } export interface GroupUsersUpdateMessageInterface { diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 95c91cd5..0f932901 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -636,6 +636,7 @@ export class RoomConnection implements RoomConnection { groupId: message.groupId, position: position, groupSize: message.groupSize, + locked: message.locked, }; } @@ -851,6 +852,20 @@ export class RoomConnection implements RoomConnection { this.socket.send(bytes); } + public emitLockGroup(groupId: number, lock: boolean = true): void { + const bytes = ClientToServerMessageTsProto.encode({ + message: { + $case: "lockGroupMessage", + lockGroupMessage: { + groupId, + lock, + }, + }, + }).finish(); + + this.socket.send(bytes); + } + public getAllTags(): string[] { return this.tags; } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 0a44cea3..c0d82d24 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -718,6 +718,16 @@ export class GameScene extends DirtyScene { e ) ); + + this.input.keyboard.on("keydown-L", (event: Event) => { + console.log("group locked"); + this.connection?.emitLockGroup(1, true); + }); + + this.input.keyboard.on("keydown-U", (event: Event) => { + console.log("group unlocked"); + this.connection?.emitLockGroup(1, false); + }); } /** @@ -782,6 +792,7 @@ export class GameScene extends DirtyScene { this.connection.groupUpdateMessageStream.subscribe( (groupPositionMessage: GroupCreatedUpdatedMessageInterface) => { + console.log(groupPositionMessage); this.shareGroupPosition(groupPositionMessage); } ); @@ -1809,8 +1820,13 @@ ${escapedMessage} break; } case "GroupCreatedUpdatedEvent": + console.log("CREATE OR UPDATE GROUP"); this.doShareGroupPosition(event.event); break; + // TODO: CALL THIS ON GROUP LOCK CHANGE + // case "GroupCreatedUpdatedEvent": + // this.doShareGroupPosition(event.event); + // break; case "DeleteGroupEvent": this.doDeleteGroup(event.groupId); break; @@ -1985,7 +2001,9 @@ ${escapedMessage} this, Math.round(groupPositionMessage.position.x), Math.round(groupPositionMessage.position.y), - groupPositionMessage.groupSize === MAX_PER_GROUP ? "circleSprite-red" : "circleSprite-white" + groupPositionMessage.groupSize === MAX_PER_GROUP || groupPositionMessage.locked + ? "circleSprite-red" + : "circleSprite-white" ); sprite.setDisplayOrigin(48, 48); this.add.existing(sprite); diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 5c9c95b7..4ccaed4b 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -98,6 +98,11 @@ message FollowAbortMessage { int32 follower = 2; } +message LockGroupMessage { + int32 groupId = 1; + bool lock = 2; +} + message ClientToServerMessage { oneof message { UserMovesMessage userMovesMessage = 2; @@ -116,6 +121,7 @@ message ClientToServerMessage { FollowRequestMessage followRequestMessage = 15; FollowConfirmationMessage followConfirmationMessage = 16; FollowAbortMessage followAbortMessage = 17; + LockGroupMessage lockGroupMessage = 18; } } @@ -172,6 +178,7 @@ message SubMessage { VariableMessage variableMessage = 8; ErrorMessage errorMessage = 9; PlayerDetailsUpdatedMessage playerDetailsUpdatedMessage = 10; + LockGroupMessage lockGroupMessage = 11; } } @@ -184,6 +191,7 @@ message GroupUpdateMessage { int32 groupId = 1; PointMessage position = 2; int32 groupSize = 3; + bool locked = 4; } message GroupDeleteMessage { @@ -316,6 +324,7 @@ message ServerToClientMessage { FollowConfirmationMessage followConfirmationMessage = 22; FollowAbortMessage followAbortMessage = 23; GroupUsersUpdateMessage groupUsersUpdateMessage = 24; + LockGroupMessage lockGroupMessage = 25; } } @@ -358,6 +367,7 @@ message GroupUpdateZoneMessage { PointMessage position = 2; int32 groupSize = 3; Zone fromZone = 4; + bool locked = 5; } message GroupLeftZoneMessage { @@ -403,6 +413,7 @@ message PusherToBackMessage { FollowRequestMessage followRequestMessage = 16; FollowConfirmationMessage followConfirmationMessage = 17; FollowAbortMessage followAbortMessage = 18; + LockGroupMessage lockGroupMessage = 19; } } diff --git a/pusher/src/Controller/IoSocketController.ts b/pusher/src/Controller/IoSocketController.ts index 6db53403..617da341 100644 --- a/pusher/src/Controller/IoSocketController.ts +++ b/pusher/src/Controller/IoSocketController.ts @@ -21,6 +21,7 @@ import { FollowConfirmationMessage, FollowAbortMessage, VariableMessage, + LockGroupMessage, } from "../Messages/generated/messages_pb"; import { UserMovesMessage } from "../Messages/generated/messages_pb"; import { TemplatedApp } from "uWebSockets.js"; @@ -494,6 +495,8 @@ export class IoSocketController { ); } else if (message.hasFollowabortmessage()) { socketManager.handleFollowAbort(client, message.getFollowabortmessage() as FollowAbortMessage); + } else if (message.hasLockgroupmessage()) { + socketManager.handleLockGroup(client, message.getLockgroupmessage() as LockGroupMessage); } /* Ok is false if backpressure was built up, wait for drain */ diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index 2132ff39..1bf1090a 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -32,6 +32,7 @@ export interface ZoneEventListener { onGroupEnters(group: GroupDescriptor, listener: ExSocketInterface): void; onGroupMoves(group: GroupDescriptor, listener: ExSocketInterface): void; onGroupLeaves(groupId: number, listener: ExSocketInterface): void; + // onGroupLock(groupId: number, listener: ExSocketInterface): void; onEmote(emoteMessage: EmoteEventMessage, listener: ExSocketInterface): void; onError(errorMessage: ErrorMessage, listener: ExSocketInterface): void; onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ExSocketInterface): void; @@ -123,19 +124,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,6 +153,7 @@ export class GroupDescriptor { groupUpdateMessage.setGroupid(this.groupId); groupUpdateMessage.setGroupsize(this.groupSize); groupUpdateMessage.setPosition(this.position); + groupUpdateMessage.setLocked(this.locked); return groupUpdateMessage; } @@ -238,6 +246,9 @@ export class Zone { } else if (message.hasEmoteeventmessage()) { const emoteEventMessage = message.getEmoteeventmessage() as EmoteEventMessage; this.notifyEmote(emoteEventMessage); + } else if (message.hasEmoteeventmessage()) { + const emoteEventMessage = message.getEmoteeventmessage() as EmoteEventMessage; + this.notifyEmote(emoteEventMessage); } else if (message.hasPlayerdetailsupdatedmessage()) { const playerDetailsUpdatedMessage = message.getPlayerdetailsupdatedmessage() as PlayerDetailsUpdatedMessage; diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index 30fe761f..b1006bf8 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -38,6 +38,7 @@ import { ErrorMessage, WorldFullMessage, PlayerDetailsUpdatedMessage, + LockGroupMessage, } from "../Messages/generated/messages_pb"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY } from "../Enum/EnvironmentVariable"; @@ -292,6 +293,12 @@ export class SocketManager implements ZoneEventListener { client.backConnection.write(pusherToBackMessage); } + handleLockGroup(client: ExSocketInterface, message: LockGroupMessage): void { + const pusherToBackMessage = new PusherToBackMessage(); + pusherToBackMessage.setLockgroupmessage(message); + client.backConnection.write(pusherToBackMessage); + } + onEmote(emoteMessage: EmoteEventMessage, listener: ExSocketInterface): void { const subMessage = new SubMessage(); subMessage.setEmoteeventmessage(emoteMessage); From ef22d4ba209972b61f64810c9ffd0d1701323397 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Wed, 2 Mar 2022 10:44:26 +0100 Subject: [PATCH 07/33] listening to lockGroupMessage on front --- back/src/Model/GameRoom.ts | 12 +++++ back/src/Model/PositionNotifier.ts | 13 ++++- back/src/Model/Zone.ts | 10 ++++ back/src/RoomManager.ts | 1 + back/src/Services/SocketManager.ts | 26 ++++++++-- back/tests/PositionNotifierTest.ts | 2 + front/src/Connexion/ConnexionModels.ts | 5 ++ front/src/Connexion/RoomConnection.ts | 10 +++- front/src/Phaser/Game/GameScene.ts | 66 +++++++++++++++++++++----- messages/protos/messages.proto | 1 + pusher/src/Model/Zone.ts | 15 ++++-- pusher/src/Services/SocketManager.ts | 7 +++ 12 files changed, 145 insertions(+), 23 deletions(-) diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index b55c6079..d6a6c7c2 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -6,6 +6,7 @@ import { EmoteCallback, EntersCallback, LeavesCallback, + LockGroupCallback, MovesCallback, PlayerDetailsUpdatedCallback, } from "_Model/Zone"; @@ -22,6 +23,7 @@ import { VariableMessage, VariableWithTagMessage, ServerToClientMessage, + LockGroupMessage, } from "../Messages/generated/messages_pb"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; import { RoomSocket, ZoneSocket } from "src/RoomManager"; @@ -66,6 +68,7 @@ export class GameRoom { onMoves: MovesCallback, onLeaves: LeavesCallback, onEmote: EmoteCallback, + onLockGroup: LockGroupCallback, onPlayerDetailsUpdated: PlayerDetailsUpdatedCallback ) { // A zone is 10 sprites wide. @@ -76,6 +79,7 @@ export class GameRoom { onMoves, onLeaves, onEmote, + onLockGroup, onPlayerDetailsUpdated ); } @@ -90,6 +94,7 @@ export class GameRoom { onMoves: MovesCallback, onLeaves: LeavesCallback, onEmote: EmoteCallback, + onLockGroup: LockGroupCallback, onPlayerDetailsUpdated: PlayerDetailsUpdatedCallback ): Promise { const mapDetails = await GameRoom.getMapDetails(roomUrl); @@ -105,6 +110,7 @@ export class GameRoom { onMoves, onLeaves, onEmote, + onLockGroup, onPlayerDetailsUpdated ); @@ -544,6 +550,12 @@ export class GameRoom { this.positionNotifier.emitEmoteEvent(user, emoteEventMessage); } + public emitLockGroupMessage(user: User, lockGroupMessage: LockGroupMessage) { + console.log("D2 GAME ROOM EMIT LOCK GROUP MESSAGE"); + console.log(lockGroupMessage.getGroupid()); + this.positionNotifier.emitLockGroupEvent(user, lockGroupMessage); + } + public addRoomListener(socket: RoomSocket) { this.roomListeners.add(socket); } diff --git a/back/src/Model/PositionNotifier.ts b/back/src/Model/PositionNotifier.ts index b059999a..ad7334f9 100644 --- a/back/src/Model/PositionNotifier.ts +++ b/back/src/Model/PositionNotifier.ts @@ -12,6 +12,7 @@ import { EmoteCallback, EntersCallback, LeavesCallback, + LockGroupCallback, MovesCallback, PlayerDetailsUpdatedCallback, Zone, @@ -20,7 +21,7 @@ import { Movable } from "_Model/Movable"; import { PositionInterface } from "_Model/PositionInterface"; import { ZoneSocket } from "../RoomManager"; import { User } from "../Model/User"; -import { EmoteEventMessage, SetPlayerDetailsMessage } from "../Messages/generated/messages_pb"; +import { EmoteEventMessage, LockGroupMessage, SetPlayerDetailsMessage } from "../Messages/generated/messages_pb"; interface ZoneDescriptor { i: number; @@ -50,6 +51,7 @@ export class PositionNotifier { private onUserMoves: MovesCallback, private onUserLeaves: LeavesCallback, private onEmote: EmoteCallback, + private onLockGroup: LockGroupCallback, private onPlayerDetailsUpdated: PlayerDetailsUpdatedCallback ) {} @@ -111,6 +113,7 @@ export class PositionNotifier { this.onUserMoves, this.onUserLeaves, this.onEmote, + this.onLockGroup, this.onPlayerDetailsUpdated, i, j @@ -137,6 +140,14 @@ export class PositionNotifier { zone.emitEmoteEvent(emoteEventMessage); } + public emitLockGroupEvent(user: User, lockGroupMessage: LockGroupMessage) { + const zoneDesc = this.getZoneDescriptorFromCoordinates(user.getPosition().x, user.getPosition().y); + const zone = this.getZone(zoneDesc.i, zoneDesc.j); + console.log("D3 emit from ZONE"); + console.log(lockGroupMessage.getGroupid()); + zone.emitLockGroupEvent(lockGroupMessage); + } + public *getAllUsersInSquareAroundZone(zone: Zone): Generator { const zoneDescriptor = this.getZoneDescriptorFromCoordinates(zone.x, zone.y); for (const d of getNearbyDescriptorsMatrix(zoneDescriptor)) { diff --git a/back/src/Model/Zone.ts b/back/src/Model/Zone.ts index 5c3e92ba..35bb4660 100644 --- a/back/src/Model/Zone.ts +++ b/back/src/Model/Zone.ts @@ -7,12 +7,14 @@ import { EmoteEventMessage, SetPlayerDetailsMessage, PlayerDetailsUpdatedMessage, + LockGroupMessage, } from "../Messages/generated/messages_pb"; export type EntersCallback = (thing: Movable, fromZone: Zone | null, listener: ZoneSocket) => void; export type MovesCallback = (thing: Movable, position: PositionInterface, listener: ZoneSocket) => void; export type LeavesCallback = (thing: Movable, newZone: Zone | null, listener: ZoneSocket) => void; export type EmoteCallback = (emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) => void; +export type LockGroupCallback = (lockGroupMessage: LockGroupMessage, listener: ZoneSocket) => void; export type PlayerDetailsUpdatedCallback = ( playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket @@ -27,6 +29,7 @@ export class Zone { private onMoves: MovesCallback, private onLeaves: LeavesCallback, private onEmote: EmoteCallback, + private onLockGroup: LockGroupCallback, private onPlayerDetailsUpdated: PlayerDetailsUpdatedCallback, public readonly x: number, public readonly y: number @@ -108,6 +111,13 @@ export class Zone { } } + public emitLockGroupEvent(lockGroupMessage: LockGroupMessage) { + console.log("D4 ZONE ON LOCK GROUP CALLBACK"); + for (const listener of this.listeners) { + this.onLockGroup(lockGroupMessage, listener); + } + } + public updatePlayerDetails(user: User, playerDetails: SetPlayerDetailsMessage) { const playerDetailsUpdatedMessage = new PlayerDetailsUpdatedMessage(); playerDetailsUpdatedMessage.setUserid(user.id); diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index b5e27982..6a091054 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -138,6 +138,7 @@ const roomManager: IRoomManagerServer = { ); } else if (message.hasLockgroupmessage()) { socketManager.handleLockGroupMessage( + room, user, message.getLockgroupmessage() as LockGroupMessage ); diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index af0ec6cf..aaa373fb 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -285,6 +285,8 @@ export class SocketManager { this.onClientLeave(thing, newZone, listener), (emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) => this.onEmote(emoteEventMessage, listener), + (lockGroupMessage: LockGroupMessage, listener: ZoneSocket) => + this.onLockGroup(lockGroupMessage, listener), (playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket) => this.onPlayerDetailsUpdated(playerDetailsUpdatedMessage, listener) ) @@ -388,6 +390,16 @@ export class SocketManager { emitZoneMessage(subMessage, client); } + private onLockGroup(lockGroupMessage: LockGroupMessage, client: ZoneSocket) { + const subMessage = new SubToPusherMessage(); + subMessage.setLockgroupmessage(lockGroupMessage); + console.log("D5 SOCKET MANAGER ON LOCK GROUP"); + console.log(lockGroupMessage.getGroupid()); + console.log(lockGroupMessage.getLock()); + + emitZoneMessage(subMessage, client); + } + private onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, client: ZoneSocket) { const subMessage = new SubToPusherMessage(); subMessage.setPlayerdetailsupdatedmessage(playerDetailsUpdatedMessage); @@ -892,9 +904,17 @@ export class SocketManager { } } - handleLockGroupMessage(user: User, message: LockGroupMessage) { - console.log(`lock group: ${message.getLock()}`); - user.group?.lock(message.getLock()); + handleLockGroupMessage(room: GameRoom, user: User, message: LockGroupMessage) { + console.log("D1 HANDLE LOCK GROUP MESSAGE"); + const group = user.group; + if (!group) { + return; + } + group.lock(message.getLock()); + const lockGroupMessage = new LockGroupMessage(); + lockGroupMessage.setLock(message.getLock()); + lockGroupMessage.setGroupid(message.getGroupid()); + room.emitLockGroupMessage(user, lockGroupMessage); } } diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index bf7ddd6e..f21bb4b2 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -25,6 +25,7 @@ describe("PositionNotifier", () => { leaveTriggered = true; }, () => {}, + () => {}, () => {} ); @@ -132,6 +133,7 @@ describe("PositionNotifier", () => { leaveTriggered = true; }, () => {}, + () => {}, () => {} ); diff --git a/front/src/Connexion/ConnexionModels.ts b/front/src/Connexion/ConnexionModels.ts index 04282abc..5b41e602 100644 --- a/front/src/Connexion/ConnexionModels.ts +++ b/front/src/Connexion/ConnexionModels.ts @@ -48,6 +48,11 @@ export interface GroupCreatedUpdatedMessageInterface { locked: boolean; } +export interface LockGroupMessageInterface { + groupId: number; + locked: boolean; +} + export interface GroupUsersUpdateMessageInterface { groupId: number; userIds: number[]; diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 0f932901..3d69f38a 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -40,6 +40,7 @@ import { PositionMessage_Direction, SetPlayerDetailsMessage as SetPlayerDetailsMessageTsProto, PingMessage as PingMessageTsProto, + LockGroupMessage, } from "../Messages/ts-proto-generated/messages"; import { Subject } from "rxjs"; @@ -101,6 +102,9 @@ export class RoomConnection implements RoomConnection { private readonly _groupUsersUpdateMessageStream = new Subject(); public readonly groupUsersUpdateMessageStream = this._groupUsersUpdateMessageStream.asObservable(); + private readonly _lockGroupMessageStream = new Subject(); + public readonly lockGroupMessageStream = this._lockGroupMessageStream.asObservable(); + private readonly _groupDeleteMessageStream = new Subject(); public readonly groupDeleteMessageStream = this._groupDeleteMessageStream.asObservable(); @@ -264,6 +268,10 @@ export class RoomConnection implements RoomConnection { this._emoteEventMessageStream.next(subMessage.emoteEventMessage); break; } + case "lockGroupMessage": { + this._lockGroupMessageStream.next(subMessage.lockGroupMessage); + break; + } case "playerDetailsUpdatedMessage": { this._playerDetailsUpdatedMessageStream.next(subMessage.playerDetailsUpdatedMessage); break; @@ -403,8 +411,6 @@ export class RoomConnection implements RoomConnection { break; } case "groupUsersUpdateMessage": { - console.log("GOT GROUP USERS UPDATE MESSAGE"); - console.log(message.groupUsersUpdateMessage); this._groupUsersUpdateMessageStream.next(message.groupUsersUpdateMessage); break; } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index c0d82d24..7b92a5d1 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -51,6 +51,7 @@ import { PathfindingManager } from "../../Utils/PathfindingManager"; import { ActivatablesManager } from "./ActivatablesManager"; import type { GroupCreatedUpdatedMessageInterface, + LockGroupMessageInterface, MessageUserMovedInterface, MessageUserPositionInterface, OnConnectInterface, @@ -132,6 +133,11 @@ interface DeleteGroupEventInterface { groupId: number; } +interface LockGroupEventInterface { + type: "LockGroupEvent"; + event: LockGroupMessageInterface; +} + interface PlayerDetailsUpdatedInterface { type: "PlayerDetailsUpdated"; details: PlayerDetailsUpdatedMessageInterface; @@ -147,6 +153,7 @@ export class GameScene extends DirtyScene { mapFile!: ITiledMap; animatedTiles!: AnimatedTiles; groups: Map; + currentPlayerGroupId?: number; circleTexture!: CanvasTexture; circleRedTexture!: CanvasTexture; pendingEvents = new Queue< @@ -156,6 +163,7 @@ export class GameScene extends DirtyScene { | UserMovedEventInterface | GroupCreatedUpdatedEventInterface | DeleteGroupEventInterface + | LockGroupEventInterface | PlayerDetailsUpdatedInterface >(); private initPosition: PositionInterface | null = null; @@ -225,6 +233,7 @@ export class GameScene extends DirtyScene { }); this.Terrains = []; this.groups = new Map(); + this.currentPlayerGroupId = undefined; this.instance = room.getInstance(); this.MapUrlFile = MapUrlFile; @@ -720,13 +729,17 @@ export class GameScene extends DirtyScene { ); this.input.keyboard.on("keydown-L", (event: Event) => { - console.log("group locked"); - this.connection?.emitLockGroup(1, true); + if (this.currentPlayerGroupId !== undefined) { + console.log("group locked"); + this.connection?.emitLockGroup(this.currentPlayerGroupId, true); + } }); this.input.keyboard.on("keydown-U", (event: Event) => { - console.log("group unlocked"); - this.connection?.emitLockGroup(1, false); + if (this.currentPlayerGroupId !== undefined) { + console.log("group unlocked"); + this.connection?.emitLockGroup(this.currentPlayerGroupId, false); + } }); } @@ -792,7 +805,6 @@ export class GameScene extends DirtyScene { this.connection.groupUpdateMessageStream.subscribe( (groupPositionMessage: GroupCreatedUpdatedMessageInterface) => { - console.log(groupPositionMessage); this.shareGroupPosition(groupPositionMessage); } ); @@ -805,6 +817,10 @@ export class GameScene extends DirtyScene { } }); + this.connection.lockGroupMessageStream.subscribe((message) => { + this.lockGroup(message); + }); + this.connection.onServerDisconnected(() => { console.log("Player disconnected from server. Reloading scene."); this.cleanupClosingScene(); @@ -838,6 +854,12 @@ export class GameScene extends DirtyScene { }); }); + this.connection.groupUsersUpdateMessageStream.subscribe((message) => { + this.currentPlayerGroupId = message.groupId; + console.log("GOT GROUP USERS UPDATE MESSAGE"); + console.log(message); + }); + /** * Triggered when we receive the JWT token to connect to Jitsi */ @@ -1820,19 +1842,22 @@ ${escapedMessage} break; } case "GroupCreatedUpdatedEvent": - console.log("CREATE OR UPDATE GROUP"); this.doShareGroupPosition(event.event); break; - // TODO: CALL THIS ON GROUP LOCK CHANGE - // case "GroupCreatedUpdatedEvent": - // this.doShareGroupPosition(event.event); - // break; - case "DeleteGroupEvent": - this.doDeleteGroup(event.groupId); - break; case "PlayerDetailsUpdated": this.doUpdatePlayerDetails(event.details); break; + case "DeleteGroupEvent": { + this.doDeleteGroup(event.groupId); + if (this.currentPlayerGroupId === event.groupId) { + this.currentPlayerGroupId = undefined; + } + break; + } + case "LockGroupEvent": { + this.doLockGroup(event.event); + break; + } default: { const tmp: never = event; } @@ -2027,6 +2052,21 @@ ${escapedMessage} this.groups.delete(groupId); } + lockGroup(event: LockGroupMessageInterface): void { + this.pendingEvents.enqueue({ + type: "LockGroupEvent", + event, + }); + } + + doLockGroup(event: LockGroupMessageInterface): void { + const group = this.groups.get(event.groupId); + if (!group) { + return; + } + group.setTexture(event.lock ? "circleSprite-red" : "circleSprite-white"); + } + doUpdatePlayerDetails(message: PlayerDetailsUpdatedMessageInterface): void { const character = this.MapPlayersByKey.get(message.userId); if (character === undefined) { diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 4ccaed4b..4708f37d 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -434,6 +434,7 @@ message SubToPusherMessage { EmoteEventMessage emoteEventMessage = 9; ErrorMessage errorMessage = 10; PlayerDetailsUpdatedMessage playerDetailsUpdatedMessage = 11; + LockGroupMessage lockGroupMessage = 12; } } diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index 1bf1090a..50d684a1 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -18,6 +18,7 @@ import { ErrorMessage, PlayerDetailsUpdatedMessage, SetPlayerDetailsMessage, + LockGroupMessage, } from "../Messages/generated/messages_pb"; import { ClientReadableStream } from "grpc"; import { PositionDispatcher } from "_Model/PositionDispatcher"; @@ -32,7 +33,7 @@ export interface ZoneEventListener { onGroupEnters(group: GroupDescriptor, listener: ExSocketInterface): void; onGroupMoves(group: GroupDescriptor, listener: ExSocketInterface): void; onGroupLeaves(groupId: number, listener: ExSocketInterface): void; - // onGroupLock(groupId: number, listener: ExSocketInterface): void; + onLockGroup(lockGroupMessage: LockGroupMessage, listener: ExSocketInterface): void; onEmote(emoteMessage: EmoteEventMessage, listener: ExSocketInterface): void; onError(errorMessage: ErrorMessage, listener: ExSocketInterface): void; onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ExSocketInterface): void; @@ -246,9 +247,9 @@ export class Zone { } else if (message.hasEmoteeventmessage()) { const emoteEventMessage = message.getEmoteeventmessage() as EmoteEventMessage; this.notifyEmote(emoteEventMessage); - } else if (message.hasEmoteeventmessage()) { - const emoteEventMessage = message.getEmoteeventmessage() as EmoteEventMessage; - this.notifyEmote(emoteEventMessage); + } else if (message.hasLockgroupmessage()) { + const lockGroupMessage = message.getLockgroupmessage() as LockGroupMessage; + this.notifyLockGroup(lockGroupMessage); } else if (message.hasPlayerdetailsupdatedmessage()) { const playerDetailsUpdatedMessage = message.getPlayerdetailsupdatedmessage() as PlayerDetailsUpdatedMessage; @@ -359,6 +360,12 @@ export class Zone { } } + private notifyLockGroup(lockGroupMessage: LockGroupMessage) { + for (const listener of this.listeners) { + this.socketListener.onLockGroup(lockGroupMessage, listener); + } + } + private notifyPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage) { for (const listener of this.listeners) { if (listener.userId === playerDetailsUpdatedMessage.getUserid()) { diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index b1006bf8..96e599e0 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -306,6 +306,13 @@ export class SocketManager implements ZoneEventListener { emitInBatch(listener, subMessage); } + onLockGroup(lockGroupMessage: LockGroupMessage, listener: ExSocketInterface): void { + const subMessage = new SubMessage(); + subMessage.setLockgroupmessage(lockGroupMessage); + + emitInBatch(listener, subMessage); + } + onPlayerDetailsUpdated( playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ExSocketInterface From a0205bf682ef301922c99c587aa493bd4b7c68ea Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Wed, 2 Mar 2022 17:00:43 +0100 Subject: [PATCH 08/33] cleanup --- back/src/Model/GameRoom.ts | 2 - back/src/Model/PositionNotifier.ts | 2 - back/src/Model/Zone.ts | 1 - back/src/RoomManager.ts | 2 - back/src/Services/SocketManager.ts | 15 ++------ front/src/Components/CameraControls.svelte | 30 ++++++++++++++- front/src/Components/images/lock.svg | 1 + .../images/lock.svg:Zone.Identifier | 3 ++ front/src/Connexion/ConnexionModels.ts | 2 +- front/src/Phaser/Game/GameScene.ts | 37 ++++++++----------- front/src/Stores/CurrentPlayerGroupStore.ts | 4 ++ messages/protos/messages.proto | 1 - pusher/src/Model/Zone.ts | 1 - 13 files changed, 57 insertions(+), 44 deletions(-) create mode 100644 front/src/Components/images/lock.svg create mode 100644 front/src/Components/images/lock.svg:Zone.Identifier create mode 100644 front/src/Stores/CurrentPlayerGroupStore.ts diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index d6a6c7c2..74284ab2 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -551,8 +551,6 @@ export class GameRoom { } public emitLockGroupMessage(user: User, lockGroupMessage: LockGroupMessage) { - console.log("D2 GAME ROOM EMIT LOCK GROUP MESSAGE"); - console.log(lockGroupMessage.getGroupid()); this.positionNotifier.emitLockGroupEvent(user, lockGroupMessage); } diff --git a/back/src/Model/PositionNotifier.ts b/back/src/Model/PositionNotifier.ts index ad7334f9..6e1fb195 100644 --- a/back/src/Model/PositionNotifier.ts +++ b/back/src/Model/PositionNotifier.ts @@ -143,8 +143,6 @@ export class PositionNotifier { public emitLockGroupEvent(user: User, lockGroupMessage: LockGroupMessage) { const zoneDesc = this.getZoneDescriptorFromCoordinates(user.getPosition().x, user.getPosition().y); const zone = this.getZone(zoneDesc.i, zoneDesc.j); - console.log("D3 emit from ZONE"); - console.log(lockGroupMessage.getGroupid()); zone.emitLockGroupEvent(lockGroupMessage); } diff --git a/back/src/Model/Zone.ts b/back/src/Model/Zone.ts index 35bb4660..4f49ff55 100644 --- a/back/src/Model/Zone.ts +++ b/back/src/Model/Zone.ts @@ -112,7 +112,6 @@ export class Zone { } public emitLockGroupEvent(lockGroupMessage: LockGroupMessage) { - console.log("D4 ZONE ON LOCK GROUP CALLBACK"); for (const listener of this.listeners) { this.onLockGroup(lockGroupMessage, listener); } diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index 6a091054..8a840c15 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -155,8 +155,6 @@ const roomManager: IRoomManagerServer = { user, setPlayerDetailsMessage as SetPlayerDetailsMessage ); - } else if (message.hasLockgroupmessage()) { - console.log("===== GOT LOCK GROUP MESSAGE FROM CLIENT ====="); } else { throw new Error("Unhandled message type"); } diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index aaa373fb..2bfe7cf2 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -70,7 +70,6 @@ function emitZoneMessage(subMessage: SubToPusherMessage, socket: ZoneSocket): vo // TODO: should we batch those every 100ms? const batchMessage = new BatchToPusherMessage(); batchMessage.addPayload(subMessage); - socket.write(batchMessage); } @@ -277,8 +276,9 @@ export class SocketManager { }, MINIMUM_DISTANCE, GROUP_RADIUS, - (thing: Movable, fromZone: Zone | null, listener: ZoneSocket) => - this.onZoneEnter(thing, fromZone, listener), + (thing: Movable, fromZone: Zone | null, listener: ZoneSocket) => { + this.onZoneEnter(thing, fromZone, listener); + }, (thing: Movable, position: PositionInterface, listener: ZoneSocket) => this.onClientMove(thing, position, listener), (thing: Movable, newZone: Zone | null, listener: ZoneSocket) => @@ -393,17 +393,12 @@ export class SocketManager { private onLockGroup(lockGroupMessage: LockGroupMessage, client: ZoneSocket) { const subMessage = new SubToPusherMessage(); subMessage.setLockgroupmessage(lockGroupMessage); - console.log("D5 SOCKET MANAGER ON LOCK GROUP"); - console.log(lockGroupMessage.getGroupid()); - console.log(lockGroupMessage.getLock()); - emitZoneMessage(subMessage, client); } private onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, client: ZoneSocket) { const subMessage = new SubToPusherMessage(); subMessage.setPlayerdetailsupdatedmessage(playerDetailsUpdatedMessage); - emitZoneMessage(subMessage, client); } @@ -433,7 +428,6 @@ export class SocketManager { const subMessage = new SubToPusherMessage(); subMessage.setGroupleftzonemessage(groupDeleteMessage); - emitZoneMessage(subMessage, client); //user.emitInBatch(subMessage); } @@ -445,7 +439,6 @@ export class SocketManager { const subMessage = new SubToPusherMessage(); subMessage.setUserleftzonemessage(userLeftMessage); - emitZoneMessage(subMessage, client); } @@ -667,6 +660,7 @@ export class SocketManager { const groupUpdateMessage = new GroupUpdateZoneMessage(); groupUpdateMessage.setGroupid(thing.getId()); groupUpdateMessage.setPosition(ProtobufUtils.toPointMessage(thing.getPosition())); + groupUpdateMessage.setLocked(thing.isLocked()); const subMessage = new SubToPusherMessage(); subMessage.setGroupupdatezonemessage(groupUpdateMessage); @@ -905,7 +899,6 @@ export class SocketManager { } handleLockGroupMessage(room: GameRoom, user: User, message: LockGroupMessage) { - console.log("D1 HANDLE LOCK GROUP MESSAGE"); const group = user.group; if (!group) { return; diff --git a/front/src/Components/CameraControls.svelte b/front/src/Components/CameraControls.svelte index bfe1d9d0..7b189aff 100644 --- a/front/src/Components/CameraControls.svelte +++ b/front/src/Components/CameraControls.svelte @@ -10,12 +10,14 @@ import layoutPresentationImg from "./images/layout-presentation.svg"; import layoutChatImg from "./images/layout-chat.svg"; import followImg from "./images/follow.svg"; + import lockImg from "./images/lock.svg"; import { LayoutMode } from "../WebRtc/LayoutManager"; import { peerStore } from "../Stores/PeerStore"; import { onDestroy } from "svelte"; import { embedScreenLayout } from "../Stores/EmbedScreensStore"; import { followRoleStore, followStateStore, followUsersStore } from "../Stores/FollowStore"; import { gameManager } from "../Phaser/Game/GameManager"; + import { currentPlayerGroupIdStore, currentPlayerGroupLockStateStore } from "../Stores/CurrentPlayerGroupStore"; const gameScene = gameManager.getCurrentGameScene(); @@ -70,6 +72,15 @@ } } + function lockClick() { + console.log($currentPlayerGroupIdStore); + console.log($currentPlayerGroupLockStateStore); + if ($currentPlayerGroupIdStore === undefined) { + return; + } + gameScene.connection?.emitLockGroup($currentPlayerGroupIdStore, !$currentPlayerGroupLockStateStore); + } + let isSilent: boolean; const unsubscribeIsSilent = isSilentStore.subscribe((value) => { isSilent = value; @@ -95,6 +106,15 @@ +
+ +
+
\ No newline at end of file diff --git a/front/src/Components/images/lock.svg:Zone.Identifier b/front/src/Components/images/lock.svg:Zone.Identifier new file mode 100644 index 00000000..053d1127 --- /dev/null +++ b/front/src/Components/images/lock.svg:Zone.Identifier @@ -0,0 +1,3 @@ +[ZoneTransfer] +ZoneId=3 +HostUrl=about:internet diff --git a/front/src/Connexion/ConnexionModels.ts b/front/src/Connexion/ConnexionModels.ts index 5b41e602..167624e6 100644 --- a/front/src/Connexion/ConnexionModels.ts +++ b/front/src/Connexion/ConnexionModels.ts @@ -50,7 +50,7 @@ export interface GroupCreatedUpdatedMessageInterface { export interface LockGroupMessageInterface { groupId: number; - locked: boolean; + lock: boolean; } export interface GroupUsersUpdateMessageInterface { diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 7b92a5d1..8b2112b9 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -77,6 +77,7 @@ import { userIsAdminStore } from "../../Stores/GameStore"; import { contactPageStore } from "../../Stores/MenuStore"; import type { WasCameraUpdatedEvent } from "../../Api/Events/WasCameraUpdatedEvent"; import { audioManagerFileStore } from "../../Stores/AudioManagerStore"; +import { currentPlayerGroupIdStore, currentPlayerGroupLockStateStore } from "../../Stores/CurrentPlayerGroupStore"; import EVENT_TYPE = Phaser.Scenes.Events; import Texture = Phaser.Textures.Texture; @@ -153,7 +154,6 @@ export class GameScene extends DirtyScene { mapFile!: ITiledMap; animatedTiles!: AnimatedTiles; groups: Map; - currentPlayerGroupId?: number; circleTexture!: CanvasTexture; circleRedTexture!: CanvasTexture; pendingEvents = new Queue< @@ -185,6 +185,7 @@ export class GameScene extends DirtyScene { private volumeStoreUnsubscribers: Map = new Map(); private localVolumeStoreUnsubscriber: Unsubscriber | undefined; private followUsersColorStoreUnsubscribe!: Unsubscriber; + private currentPlayerGroupIdStoreUnsubscribe!: Unsubscriber; private biggestAvailableAreaStoreUnsubscribe!: () => void; MapUrlFile: string; @@ -226,6 +227,7 @@ export class GameScene extends DirtyScene { private loader: Loader; private lastCameraEvent: WasCameraUpdatedEvent | undefined; private firstCameraUpdateSent: boolean = false; + private currentPlayerGroupId?: number; constructor(private room: Room, MapUrlFile: string, customKey?: string | undefined) { super({ @@ -233,7 +235,6 @@ export class GameScene extends DirtyScene { }); this.Terrains = []; this.groups = new Map(); - this.currentPlayerGroupId = undefined; this.instance = room.getInstance(); this.MapUrlFile = MapUrlFile; @@ -717,6 +718,10 @@ export class GameScene extends DirtyScene { } }); + this.currentPlayerGroupIdStoreUnsubscribe = currentPlayerGroupIdStore.subscribe((groupId) => { + this.currentPlayerGroupId = groupId; + }); + Promise.all([this.connectionAnswerPromise as Promise, ...scriptPromises]) .then(() => { this.scene.wake(); @@ -727,20 +732,6 @@ export class GameScene extends DirtyScene { e ) ); - - this.input.keyboard.on("keydown-L", (event: Event) => { - if (this.currentPlayerGroupId !== undefined) { - console.log("group locked"); - this.connection?.emitLockGroup(this.currentPlayerGroupId, true); - } - }); - - this.input.keyboard.on("keydown-U", (event: Event) => { - if (this.currentPlayerGroupId !== undefined) { - console.log("group unlocked"); - this.connection?.emitLockGroup(this.currentPlayerGroupId, false); - } - }); } /** @@ -855,9 +846,8 @@ export class GameScene extends DirtyScene { }); this.connection.groupUsersUpdateMessageStream.subscribe((message) => { - this.currentPlayerGroupId = message.groupId; - console.log("GOT GROUP USERS UPDATE MESSAGE"); - console.log(message); + // TODO: how else can we deduce our current group? + currentPlayerGroupIdStore.set(message.groupId); }); /** @@ -1849,9 +1839,8 @@ ${escapedMessage} break; case "DeleteGroupEvent": { this.doDeleteGroup(event.groupId); - if (this.currentPlayerGroupId === event.groupId) { - this.currentPlayerGroupId = undefined; - } + currentPlayerGroupIdStore.set(undefined); + currentPlayerGroupLockStateStore.set(undefined); break; } case "LockGroupEvent": { @@ -2033,6 +2022,9 @@ ${escapedMessage} sprite.setDisplayOrigin(48, 48); this.add.existing(sprite); this.groups.set(groupPositionMessage.groupId, sprite); + if (this.currentPlayerGroupId === groupPositionMessage.groupId) { + currentPlayerGroupLockStateStore.set(groupPositionMessage.locked); + } return sprite; } @@ -2064,6 +2056,7 @@ ${escapedMessage} if (!group) { return; } + currentPlayerGroupLockStateStore.set(event.lock); group.setTexture(event.lock ? "circleSprite-red" : "circleSprite-white"); } diff --git a/front/src/Stores/CurrentPlayerGroupStore.ts b/front/src/Stores/CurrentPlayerGroupStore.ts new file mode 100644 index 00000000..cda46325 --- /dev/null +++ b/front/src/Stores/CurrentPlayerGroupStore.ts @@ -0,0 +1,4 @@ +import { writable } from "svelte/store"; + +export const currentPlayerGroupIdStore = writable(undefined); +export const currentPlayerGroupLockStateStore = writable(undefined); diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 4708f37d..3db0da95 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -324,7 +324,6 @@ message ServerToClientMessage { FollowConfirmationMessage followConfirmationMessage = 22; FollowAbortMessage followAbortMessage = 23; GroupUsersUpdateMessage groupUsersUpdateMessage = 24; - LockGroupMessage lockGroupMessage = 25; } } diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index 50d684a1..451597b9 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -155,7 +155,6 @@ export class GroupDescriptor { groupUpdateMessage.setGroupsize(this.groupSize); groupUpdateMessage.setPosition(this.position); groupUpdateMessage.setLocked(this.locked); - return groupUpdateMessage; } } From a0535ed4a84cff750f7e23f8ae27dcd306723085 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Thu, 3 Mar 2022 12:22:16 +0100 Subject: [PATCH 09/33] Updating GroupDescriptors on LockGroupMessage --- back/src/RoomManager.ts | 6 +++--- back/src/Services/SocketManager.ts | 5 +++-- front/src/Components/CameraControls.svelte | 9 ++------- front/src/Connexion/RoomConnection.ts | 7 +++---- messages/protos/messages.proto | 8 ++++++-- pusher/src/Controller/IoSocketController.ts | 8 ++++++-- pusher/src/Model/PositionDispatcher.ts | 1 + pusher/src/Model/Zone.ts | 14 ++++++++++++-- pusher/src/Services/SocketManager.ts | 6 ++++-- 9 files changed, 40 insertions(+), 24 deletions(-) diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index 8a840c15..2705787e 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -29,7 +29,7 @@ import { WebRtcSignalToServerMessage, WorldFullWarningToRoomMessage, ZoneMessage, - LockGroupMessage, + LockGroupPromptMessage, } from "./Messages/generated/messages_pb"; import { sendUnaryData, ServerDuplexStream, ServerUnaryCall, ServerWritableStream } from "grpc"; import { socketManager } from "./Services/SocketManager"; @@ -136,11 +136,11 @@ const roomManager: IRoomManagerServer = { user, message.getFollowabortmessage() as FollowAbortMessage ); - } else if (message.hasLockgroupmessage()) { + } else if (message.hasLockgrouppromptmessage()) { socketManager.handleLockGroupMessage( room, user, - message.getLockgroupmessage() as LockGroupMessage + message.getLockgrouppromptmessage() as LockGroupPromptMessage ); } else if (message.hasSendusermessage()) { const sendUserMessage = message.getSendusermessage(); diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index 2bfe7cf2..0f78427f 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -40,6 +40,7 @@ import { PlayerDetailsUpdatedMessage, GroupUsersUpdateMessage, LockGroupMessage, + LockGroupPromptMessage, } from "../Messages/generated/messages_pb"; import { User, UserSocket } from "../Model/User"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; @@ -898,7 +899,7 @@ export class SocketManager { } } - handleLockGroupMessage(room: GameRoom, user: User, message: LockGroupMessage) { + handleLockGroupMessage(room: GameRoom, user: User, message: LockGroupPromptMessage) { const group = user.group; if (!group) { return; @@ -906,7 +907,7 @@ export class SocketManager { group.lock(message.getLock()); const lockGroupMessage = new LockGroupMessage(); lockGroupMessage.setLock(message.getLock()); - lockGroupMessage.setGroupid(message.getGroupid()); + lockGroupMessage.setGroupid(group.getId()); room.emitLockGroupMessage(user, lockGroupMessage); } } diff --git a/front/src/Components/CameraControls.svelte b/front/src/Components/CameraControls.svelte index 7b189aff..da207df1 100644 --- a/front/src/Components/CameraControls.svelte +++ b/front/src/Components/CameraControls.svelte @@ -17,7 +17,7 @@ import { embedScreenLayout } from "../Stores/EmbedScreensStore"; import { followRoleStore, followStateStore, followUsersStore } from "../Stores/FollowStore"; import { gameManager } from "../Phaser/Game/GameManager"; - import { currentPlayerGroupIdStore, currentPlayerGroupLockStateStore } from "../Stores/CurrentPlayerGroupStore"; + import { currentPlayerGroupLockStateStore } from "../Stores/CurrentPlayerGroupStore"; const gameScene = gameManager.getCurrentGameScene(); @@ -73,12 +73,7 @@ } function lockClick() { - console.log($currentPlayerGroupIdStore); - console.log($currentPlayerGroupLockStateStore); - if ($currentPlayerGroupIdStore === undefined) { - return; - } - gameScene.connection?.emitLockGroup($currentPlayerGroupIdStore, !$currentPlayerGroupLockStateStore); + gameScene.connection?.emitLockGroup(!$currentPlayerGroupLockStateStore); } let isSilent: boolean; diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index 3d69f38a..d0cc5c48 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -858,12 +858,11 @@ export class RoomConnection implements RoomConnection { this.socket.send(bytes); } - public emitLockGroup(groupId: number, lock: boolean = true): void { + public emitLockGroup(lock: boolean = true): void { const bytes = ClientToServerMessageTsProto.encode({ message: { - $case: "lockGroupMessage", - lockGroupMessage: { - groupId, + $case: "lockGroupPromptMessage", + lockGroupPromptMessage: { lock, }, }, diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 3db0da95..b6e8d98f 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -98,6 +98,10 @@ message FollowAbortMessage { int32 follower = 2; } +message LockGroupPromptMessage { + bool lock = 1; +} + message LockGroupMessage { int32 groupId = 1; bool lock = 2; @@ -121,7 +125,7 @@ message ClientToServerMessage { FollowRequestMessage followRequestMessage = 15; FollowConfirmationMessage followConfirmationMessage = 16; FollowAbortMessage followAbortMessage = 17; - LockGroupMessage lockGroupMessage = 18; + LockGroupPromptMessage lockGroupPromptMessage = 18; } } @@ -412,7 +416,7 @@ message PusherToBackMessage { FollowRequestMessage followRequestMessage = 16; FollowConfirmationMessage followConfirmationMessage = 17; FollowAbortMessage followAbortMessage = 18; - LockGroupMessage lockGroupMessage = 19; + LockGroupPromptMessage lockGroupPromptMessage = 19; } } diff --git a/pusher/src/Controller/IoSocketController.ts b/pusher/src/Controller/IoSocketController.ts index 617da341..7c7928d6 100644 --- a/pusher/src/Controller/IoSocketController.ts +++ b/pusher/src/Controller/IoSocketController.ts @@ -22,6 +22,7 @@ import { FollowAbortMessage, VariableMessage, LockGroupMessage, + LockGroupPromptMessage, } from "../Messages/generated/messages_pb"; import { UserMovesMessage } from "../Messages/generated/messages_pb"; import { TemplatedApp } from "uWebSockets.js"; @@ -495,8 +496,11 @@ export class IoSocketController { ); } else if (message.hasFollowabortmessage()) { socketManager.handleFollowAbort(client, message.getFollowabortmessage() as FollowAbortMessage); - } else if (message.hasLockgroupmessage()) { - socketManager.handleLockGroup(client, message.getLockgroupmessage() as LockGroupMessage); + } else if (message.hasLockgrouppromptmessage()) { + socketManager.handleLockGroup( + client, + message.getLockgrouppromptmessage() as LockGroupPromptMessage + ); } /* Ok is false if backpressure was built up, wait for drain */ diff --git a/pusher/src/Model/PositionDispatcher.ts b/pusher/src/Model/PositionDispatcher.ts index f868cd2c..b0eea0ac 100644 --- a/pusher/src/Model/PositionDispatcher.ts +++ b/pusher/src/Model/PositionDispatcher.ts @@ -63,6 +63,7 @@ export class PositionDispatcher { const addedZones = [...newZones].filter((x) => !oldZones.has(x)); const removedZones = [...oldZones].filter((x) => !newZones.has(x)); + console.log("START LISTENING"); for (const zone of addedZones) { zone.startListening(socket); } diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index 451597b9..92f82222 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -140,6 +140,10 @@ export class GroupDescriptor { return new GroupDescriptor(message.getGroupid(), message.getGroupsize(), position, message.getLocked()); } + public updateFromLockGroupMessage(message: LockGroupMessage): void { + this.locked = message.getLock(); + } + public update(groupDescriptor: GroupDescriptor) { this.groupSize = groupDescriptor.groupSize; this.position = groupDescriptor.position; @@ -214,11 +218,17 @@ export class Zone { this.notifyGroupMove(groupDescriptor); } else { this.groups.set(groupId, groupDescriptor); - const fromZone = groupUpdateZoneMessage.getFromzone(); - this.notifyGroupEnter(groupDescriptor, fromZone?.toObject()); } + } else if (message.hasLockgroupmessage()) { + const lockGroupMessage = message.getLockgroupmessage() as LockGroupMessage; + const groupId = lockGroupMessage.getGroupid(); + const oldGroupDescriptor = this.groups.get(groupId); + if (oldGroupDescriptor !== undefined) { + oldGroupDescriptor.updateFromLockGroupMessage(lockGroupMessage); + this.notifyLockGroup(lockGroupMessage); + } } else if (message.hasUserleftzonemessage()) { const userLeftMessage = message.getUserleftzonemessage() as UserLeftZoneMessage; this.users.delete(userLeftMessage.getUserid()); diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index 96e599e0..30f41f2a 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -39,6 +39,7 @@ import { WorldFullMessage, PlayerDetailsUpdatedMessage, LockGroupMessage, + LockGroupPromptMessage, } from "../Messages/generated/messages_pb"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY } from "../Enum/EnvironmentVariable"; @@ -293,9 +294,9 @@ export class SocketManager implements ZoneEventListener { client.backConnection.write(pusherToBackMessage); } - handleLockGroup(client: ExSocketInterface, message: LockGroupMessage): void { + handleLockGroup(client: ExSocketInterface, message: LockGroupPromptMessage): void { const pusherToBackMessage = new PusherToBackMessage(); - pusherToBackMessage.setLockgroupmessage(message); + pusherToBackMessage.setLockgrouppromptmessage(message); client.backConnection.write(pusherToBackMessage); } @@ -614,6 +615,7 @@ export class SocketManager implements ZoneEventListener { public onGroupEnters(group: GroupDescriptor, listener: ExSocketInterface): void { const subMessage = new SubMessage(); + console.log("ON GROUP ENTERS"); subMessage.setGroupupdatemessage(group.toGroupUpdateMessage()); emitInBatch(listener, subMessage); From 5706e5c41631f6e038f36ae7d8941219b0e80ce7 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Thu, 3 Mar 2022 12:31:17 +0100 Subject: [PATCH 10/33] remove console logs --- pusher/src/Model/PositionDispatcher.ts | 1 - pusher/src/Services/SocketManager.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/pusher/src/Model/PositionDispatcher.ts b/pusher/src/Model/PositionDispatcher.ts index b0eea0ac..f868cd2c 100644 --- a/pusher/src/Model/PositionDispatcher.ts +++ b/pusher/src/Model/PositionDispatcher.ts @@ -63,7 +63,6 @@ export class PositionDispatcher { const addedZones = [...newZones].filter((x) => !oldZones.has(x)); const removedZones = [...oldZones].filter((x) => !newZones.has(x)); - console.log("START LISTENING"); for (const zone of addedZones) { zone.startListening(socket); } diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index 30f41f2a..436ecd39 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -615,7 +615,6 @@ export class SocketManager implements ZoneEventListener { public onGroupEnters(group: GroupDescriptor, listener: ExSocketInterface): void { const subMessage = new SubMessage(); - console.log("ON GROUP ENTERS"); subMessage.setGroupupdatemessage(group.toGroupUpdateMessage()); emitInBatch(listener, subMessage); From 363b906cb825d9019f36463ead8e445f9ec5e9c5 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Thu, 3 Mar 2022 14:36:16 +0100 Subject: [PATCH 11/33] group circles with color fill --- front/src/Components/CameraControls.svelte | 2 +- front/src/Phaser/Game/GameScene.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/front/src/Components/CameraControls.svelte b/front/src/Components/CameraControls.svelte index da207df1..c22900ff 100644 --- a/front/src/Components/CameraControls.svelte +++ b/front/src/Components/CameraControls.svelte @@ -103,7 +103,7 @@
diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 8b2112b9..8b0793e0 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -980,7 +980,9 @@ export class GameScene extends DirtyScene { context.arc(48, 48, 48, 0, 2 * Math.PI, false); // context.lineWidth = 5; context.strokeStyle = "#ffffff"; + context.fillStyle = "#ffffff44"; context.stroke(); + context.fill(); this.circleTexture.refresh(); //create red circle canvas use to create sprite @@ -990,7 +992,9 @@ export class GameScene extends DirtyScene { contextRed.arc(48, 48, 48, 0, 2 * Math.PI, false); //context.lineWidth = 5; contextRed.strokeStyle = "#ff0000"; + contextRed.fillStyle = "#ff000044"; contextRed.stroke(); + contextRed.fill(); this.circleRedTexture.refresh(); } From ba612c49ed482e2af89ed96e7058e4c62d31d0a0 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Thu, 3 Mar 2022 14:47:42 +0100 Subject: [PATCH 12/33] fix GameRoom text --- back/tests/GameRoomTest.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/back/tests/GameRoomTest.ts b/back/tests/GameRoomTest.ts index d4e83daf..fb9f09fb 100644 --- a/back/tests/GameRoomTest.ts +++ b/back/tests/GameRoomTest.ts @@ -52,6 +52,7 @@ describe("GameRoom", () => { () => {}, () => {}, emote, + () => {}, () => {} ); @@ -88,6 +89,7 @@ describe("GameRoom", () => { () => {}, () => {}, emote, + () => {}, () => {} ); @@ -128,6 +130,7 @@ describe("GameRoom", () => { () => {}, () => {}, emote, + () => {}, () => {} ); From 3c74b2b554fec3dc221ffde8b766917657371296 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Thu, 3 Mar 2022 15:21:44 +0100 Subject: [PATCH 13/33] remove obsolete check --- front/src/Components/CameraControls.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/Components/CameraControls.svelte b/front/src/Components/CameraControls.svelte index c22900ff..b9cb7801 100644 --- a/front/src/Components/CameraControls.svelte +++ b/front/src/Components/CameraControls.svelte @@ -103,7 +103,7 @@
From 3a5aa3c3c55979208839659aaf57d00900910ab6 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Wed, 9 Mar 2022 16:51:11 +0100 Subject: [PATCH 14/33] cr fixes #1 wip --- back/src/Model/GameRoom.ts | 14 ++++++++----- back/src/Services/SocketManager.ts | 20 ++++++++++++++----- .../images/lock.svg:Zone.Identifier | 3 --- front/src/Phaser/Game/GameScene.ts | 1 + 4 files changed, 25 insertions(+), 13 deletions(-) delete mode 100644 front/src/Components/images/lock.svg:Zone.Identifier diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index 74284ab2..a073f0e5 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -46,7 +46,7 @@ export class GameRoom { // Users, sorted by ID private readonly users = new Map(); private readonly usersByUuid = new Map(); - private readonly groups = new Set(); + private readonly groups: Map = new Map(); private readonly admins = new Set(); private itemsState = new Map(); @@ -250,7 +250,7 @@ export class GameRoom { this.disconnectCallback, this.positionNotifier ); - this.groups.add(group); + this.groups.set(group.getId(), group); } } } else { @@ -334,7 +334,7 @@ export class GameRoom { this.disconnectCallback, this.positionNotifier ); - this.groups.add(newGroup); + this.groups.set(newGroup.getId(), newGroup); } else { this.leaveGroup(user); } @@ -381,10 +381,10 @@ export class GameRoom { group.leave(user); if (group.isEmpty()) { group.destroy(); - if (!this.groups.has(group)) { + if (!this.groups.has(group.getId())) { throw new Error(`Could not find group ${group.getId()} referenced by user ${user.id} in World.`); } - this.groups.delete(group); + this.groups.delete(group.getId()); //todo: is the group garbage collected? } else { group.updatePosition(); @@ -664,4 +664,8 @@ export class GameRoom { const variablesManager = await this.getVariableManager(); return variablesManager.getVariablesForTags(tags); } + + public getGroupById(id: number): Group | undefined { + return this.groups.get(id); + } } diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index 0f78427f..f3f34f9b 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -41,6 +41,7 @@ import { GroupUsersUpdateMessage, LockGroupMessage, LockGroupPromptMessage, + RoomMessage, } from "../Messages/generated/messages_pb"; import { User, UserSocket } from "../Model/User"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; @@ -287,7 +288,7 @@ export class SocketManager { (emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) => this.onEmote(emoteEventMessage, listener), (lockGroupMessage: LockGroupMessage, listener: ZoneSocket) => - this.onLockGroup(lockGroupMessage, listener), + this.onLockGroup(lockGroupMessage, listener, roomPromise), (playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket) => this.onPlayerDetailsUpdated(playerDetailsUpdatedMessage, listener) ) @@ -391,10 +392,19 @@ export class SocketManager { emitZoneMessage(subMessage, client); } - private onLockGroup(lockGroupMessage: LockGroupMessage, client: ZoneSocket) { - const subMessage = new SubToPusherMessage(); - subMessage.setLockgroupmessage(lockGroupMessage); - emitZoneMessage(subMessage, client); + private async onLockGroup( + lockGroupMessage: LockGroupMessage, + client: ZoneSocket, + roomPromise: PromiseLike | undefined + ) { + if (!roomPromise) { + return; + } + const group = (await roomPromise).getGroupById(lockGroupMessage.getGroupid()); + if (!group) { + return; + } + this.emitCreateUpdateGroupEvent(client, null, group); } private onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, client: ZoneSocket) { diff --git a/front/src/Components/images/lock.svg:Zone.Identifier b/front/src/Components/images/lock.svg:Zone.Identifier deleted file mode 100644 index 053d1127..00000000 --- a/front/src/Components/images/lock.svg:Zone.Identifier +++ /dev/null @@ -1,3 +0,0 @@ -[ZoneTransfer] -ZoneId=3 -HostUrl=about:internet diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 8b0793e0..e795979f 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -2010,6 +2010,7 @@ ${escapedMessage} } private doShareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface) { + console.log(groupPositionMessage); //delete previous group this.doDeleteGroup(groupPositionMessage.groupId); From 5a8cba24fa423727ea3f98466d67007d84fb57b4 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Thu, 10 Mar 2022 12:20:53 +0100 Subject: [PATCH 15/33] much cleaner approach to group lock update --- back/src/Model/GameRoom.ts | 5 ++-- back/src/Model/PositionNotifier.ts | 6 ++-- back/src/Model/Zone.ts | 7 ++--- back/src/RoomManager.ts | 2 +- back/src/Services/SocketManager.ts | 17 +++-------- front/src/Connexion/ConnexionModels.ts | 5 ---- front/src/Connexion/RoomConnection.ts | 8 ------ front/src/Phaser/Game/GameScene.ts | 31 --------------------- messages/protos/messages.proto | 7 ----- pusher/src/Controller/IoSocketController.ts | 1 - pusher/src/Model/Zone.ts | 23 --------------- pusher/src/Services/SocketManager.ts | 8 ------ 12 files changed, 13 insertions(+), 107 deletions(-) diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index a073f0e5..c1c1c346 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -23,7 +23,6 @@ import { VariableMessage, VariableWithTagMessage, ServerToClientMessage, - LockGroupMessage, } from "../Messages/generated/messages_pb"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; import { RoomSocket, ZoneSocket } from "src/RoomManager"; @@ -550,8 +549,8 @@ export class GameRoom { this.positionNotifier.emitEmoteEvent(user, emoteEventMessage); } - public emitLockGroupMessage(user: User, lockGroupMessage: LockGroupMessage) { - this.positionNotifier.emitLockGroupEvent(user, lockGroupMessage); + public emitLockGroupEvent(user: User, groupId: number) { + this.positionNotifier.emitLockGroupEvent(user, groupId); } public addRoomListener(socket: RoomSocket) { diff --git a/back/src/Model/PositionNotifier.ts b/back/src/Model/PositionNotifier.ts index 6e1fb195..38d538ec 100644 --- a/back/src/Model/PositionNotifier.ts +++ b/back/src/Model/PositionNotifier.ts @@ -21,7 +21,7 @@ import { Movable } from "_Model/Movable"; import { PositionInterface } from "_Model/PositionInterface"; import { ZoneSocket } from "../RoomManager"; import { User } from "../Model/User"; -import { EmoteEventMessage, LockGroupMessage, SetPlayerDetailsMessage } from "../Messages/generated/messages_pb"; +import { EmoteEventMessage, SetPlayerDetailsMessage } from "../Messages/generated/messages_pb"; interface ZoneDescriptor { i: number; @@ -140,10 +140,10 @@ export class PositionNotifier { zone.emitEmoteEvent(emoteEventMessage); } - public emitLockGroupEvent(user: User, lockGroupMessage: LockGroupMessage) { + public emitLockGroupEvent(user: User, groupId: number) { const zoneDesc = this.getZoneDescriptorFromCoordinates(user.getPosition().x, user.getPosition().y); const zone = this.getZone(zoneDesc.i, zoneDesc.j); - zone.emitLockGroupEvent(lockGroupMessage); + zone.emitLockGroupEvent(groupId); } public *getAllUsersInSquareAroundZone(zone: Zone): Generator { diff --git a/back/src/Model/Zone.ts b/back/src/Model/Zone.ts index 4f49ff55..2d0cefd5 100644 --- a/back/src/Model/Zone.ts +++ b/back/src/Model/Zone.ts @@ -7,14 +7,13 @@ import { EmoteEventMessage, SetPlayerDetailsMessage, PlayerDetailsUpdatedMessage, - LockGroupMessage, } from "../Messages/generated/messages_pb"; export type EntersCallback = (thing: Movable, fromZone: Zone | null, listener: ZoneSocket) => void; export type MovesCallback = (thing: Movable, position: PositionInterface, listener: ZoneSocket) => void; export type LeavesCallback = (thing: Movable, newZone: Zone | null, listener: ZoneSocket) => void; export type EmoteCallback = (emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) => void; -export type LockGroupCallback = (lockGroupMessage: LockGroupMessage, listener: ZoneSocket) => void; +export type LockGroupCallback = (groupId: number, listener: ZoneSocket) => void; export type PlayerDetailsUpdatedCallback = ( playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket @@ -111,9 +110,9 @@ export class Zone { } } - public emitLockGroupEvent(lockGroupMessage: LockGroupMessage) { + public emitLockGroupEvent(groupId: number) { for (const listener of this.listeners) { - this.onLockGroup(lockGroupMessage, listener); + this.onLockGroup(groupId, listener); } } diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index 2705787e..ab886f50 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -137,7 +137,7 @@ const roomManager: IRoomManagerServer = { message.getFollowabortmessage() as FollowAbortMessage ); } else if (message.hasLockgrouppromptmessage()) { - socketManager.handleLockGroupMessage( + socketManager.handleLockGroupPromptMessage( room, user, message.getLockgrouppromptmessage() as LockGroupPromptMessage diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index f3f34f9b..d0151e30 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -39,7 +39,6 @@ import { SetPlayerDetailsMessage, PlayerDetailsUpdatedMessage, GroupUsersUpdateMessage, - LockGroupMessage, LockGroupPromptMessage, RoomMessage, } from "../Messages/generated/messages_pb"; @@ -287,8 +286,7 @@ export class SocketManager { this.onClientLeave(thing, newZone, listener), (emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) => this.onEmote(emoteEventMessage, listener), - (lockGroupMessage: LockGroupMessage, listener: ZoneSocket) => - this.onLockGroup(lockGroupMessage, listener, roomPromise), + (groupId: number, listener: ZoneSocket) => this.onLockGroup(groupId, listener, roomPromise), (playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket) => this.onPlayerDetailsUpdated(playerDetailsUpdatedMessage, listener) ) @@ -392,15 +390,11 @@ export class SocketManager { emitZoneMessage(subMessage, client); } - private async onLockGroup( - lockGroupMessage: LockGroupMessage, - client: ZoneSocket, - roomPromise: PromiseLike | undefined - ) { + private async onLockGroup(groupId: number, client: ZoneSocket, roomPromise: PromiseLike | undefined) { if (!roomPromise) { return; } - const group = (await roomPromise).getGroupById(lockGroupMessage.getGroupid()); + const group = (await roomPromise).getGroupById(groupId); if (!group) { return; } @@ -915,10 +909,7 @@ export class SocketManager { return; } group.lock(message.getLock()); - const lockGroupMessage = new LockGroupMessage(); - lockGroupMessage.setLock(message.getLock()); - lockGroupMessage.setGroupid(group.getId()); - room.emitLockGroupMessage(user, lockGroupMessage); + room.emitLockGroupEvent(user, group.getId()); } } diff --git a/front/src/Connexion/ConnexionModels.ts b/front/src/Connexion/ConnexionModels.ts index 167624e6..04282abc 100644 --- a/front/src/Connexion/ConnexionModels.ts +++ b/front/src/Connexion/ConnexionModels.ts @@ -48,11 +48,6 @@ export interface GroupCreatedUpdatedMessageInterface { locked: boolean; } -export interface LockGroupMessageInterface { - groupId: number; - lock: boolean; -} - export interface GroupUsersUpdateMessageInterface { groupId: number; userIds: number[]; diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index d0cc5c48..48827bc5 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -40,7 +40,6 @@ import { PositionMessage_Direction, SetPlayerDetailsMessage as SetPlayerDetailsMessageTsProto, PingMessage as PingMessageTsProto, - LockGroupMessage, } from "../Messages/ts-proto-generated/messages"; import { Subject } from "rxjs"; @@ -102,9 +101,6 @@ export class RoomConnection implements RoomConnection { private readonly _groupUsersUpdateMessageStream = new Subject(); public readonly groupUsersUpdateMessageStream = this._groupUsersUpdateMessageStream.asObservable(); - private readonly _lockGroupMessageStream = new Subject(); - public readonly lockGroupMessageStream = this._lockGroupMessageStream.asObservable(); - private readonly _groupDeleteMessageStream = new Subject(); public readonly groupDeleteMessageStream = this._groupDeleteMessageStream.asObservable(); @@ -268,10 +264,6 @@ export class RoomConnection implements RoomConnection { this._emoteEventMessageStream.next(subMessage.emoteEventMessage); break; } - case "lockGroupMessage": { - this._lockGroupMessageStream.next(subMessage.lockGroupMessage); - break; - } case "playerDetailsUpdatedMessage": { this._playerDetailsUpdatedMessageStream.next(subMessage.playerDetailsUpdatedMessage); break; diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index e795979f..15570bb9 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -51,7 +51,6 @@ import { PathfindingManager } from "../../Utils/PathfindingManager"; import { ActivatablesManager } from "./ActivatablesManager"; import type { GroupCreatedUpdatedMessageInterface, - LockGroupMessageInterface, MessageUserMovedInterface, MessageUserPositionInterface, OnConnectInterface, @@ -134,11 +133,6 @@ interface DeleteGroupEventInterface { groupId: number; } -interface LockGroupEventInterface { - type: "LockGroupEvent"; - event: LockGroupMessageInterface; -} - interface PlayerDetailsUpdatedInterface { type: "PlayerDetailsUpdated"; details: PlayerDetailsUpdatedMessageInterface; @@ -163,7 +157,6 @@ export class GameScene extends DirtyScene { | UserMovedEventInterface | GroupCreatedUpdatedEventInterface | DeleteGroupEventInterface - | LockGroupEventInterface | PlayerDetailsUpdatedInterface >(); private initPosition: PositionInterface | null = null; @@ -808,10 +801,6 @@ export class GameScene extends DirtyScene { } }); - this.connection.lockGroupMessageStream.subscribe((message) => { - this.lockGroup(message); - }); - this.connection.onServerDisconnected(() => { console.log("Player disconnected from server. Reloading scene."); this.cleanupClosingScene(); @@ -1847,10 +1836,6 @@ ${escapedMessage} currentPlayerGroupLockStateStore.set(undefined); break; } - case "LockGroupEvent": { - this.doLockGroup(event.event); - break; - } default: { const tmp: never = event; } @@ -2049,22 +2034,6 @@ ${escapedMessage} this.groups.delete(groupId); } - lockGroup(event: LockGroupMessageInterface): void { - this.pendingEvents.enqueue({ - type: "LockGroupEvent", - event, - }); - } - - doLockGroup(event: LockGroupMessageInterface): void { - const group = this.groups.get(event.groupId); - if (!group) { - return; - } - currentPlayerGroupLockStateStore.set(event.lock); - group.setTexture(event.lock ? "circleSprite-red" : "circleSprite-white"); - } - doUpdatePlayerDetails(message: PlayerDetailsUpdatedMessageInterface): void { const character = this.MapPlayersByKey.get(message.userId); if (character === undefined) { diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index b6e8d98f..78858499 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -102,11 +102,6 @@ message LockGroupPromptMessage { bool lock = 1; } -message LockGroupMessage { - int32 groupId = 1; - bool lock = 2; -} - message ClientToServerMessage { oneof message { UserMovesMessage userMovesMessage = 2; @@ -182,7 +177,6 @@ message SubMessage { VariableMessage variableMessage = 8; ErrorMessage errorMessage = 9; PlayerDetailsUpdatedMessage playerDetailsUpdatedMessage = 10; - LockGroupMessage lockGroupMessage = 11; } } @@ -437,7 +431,6 @@ message SubToPusherMessage { EmoteEventMessage emoteEventMessage = 9; ErrorMessage errorMessage = 10; PlayerDetailsUpdatedMessage playerDetailsUpdatedMessage = 11; - LockGroupMessage lockGroupMessage = 12; } } diff --git a/pusher/src/Controller/IoSocketController.ts b/pusher/src/Controller/IoSocketController.ts index 7c7928d6..781b4fc0 100644 --- a/pusher/src/Controller/IoSocketController.ts +++ b/pusher/src/Controller/IoSocketController.ts @@ -21,7 +21,6 @@ import { FollowConfirmationMessage, FollowAbortMessage, VariableMessage, - LockGroupMessage, LockGroupPromptMessage, } from "../Messages/generated/messages_pb"; import { UserMovesMessage } from "../Messages/generated/messages_pb"; diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index 92f82222..02a01d8d 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -18,7 +18,6 @@ import { ErrorMessage, PlayerDetailsUpdatedMessage, SetPlayerDetailsMessage, - LockGroupMessage, } from "../Messages/generated/messages_pb"; import { ClientReadableStream } from "grpc"; import { PositionDispatcher } from "_Model/PositionDispatcher"; @@ -33,7 +32,6 @@ export interface ZoneEventListener { onGroupEnters(group: GroupDescriptor, listener: ExSocketInterface): void; onGroupMoves(group: GroupDescriptor, listener: ExSocketInterface): void; onGroupLeaves(groupId: number, listener: ExSocketInterface): void; - onLockGroup(lockGroupMessage: LockGroupMessage, listener: ExSocketInterface): void; onEmote(emoteMessage: EmoteEventMessage, listener: ExSocketInterface): void; onError(errorMessage: ErrorMessage, listener: ExSocketInterface): void; onPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ExSocketInterface): void; @@ -140,10 +138,6 @@ export class GroupDescriptor { return new GroupDescriptor(message.getGroupid(), message.getGroupsize(), position, message.getLocked()); } - public updateFromLockGroupMessage(message: LockGroupMessage): void { - this.locked = message.getLock(); - } - public update(groupDescriptor: GroupDescriptor) { this.groupSize = groupDescriptor.groupSize; this.position = groupDescriptor.position; @@ -221,14 +215,6 @@ export class Zone { const fromZone = groupUpdateZoneMessage.getFromzone(); this.notifyGroupEnter(groupDescriptor, fromZone?.toObject()); } - } else if (message.hasLockgroupmessage()) { - const lockGroupMessage = message.getLockgroupmessage() as LockGroupMessage; - const groupId = lockGroupMessage.getGroupid(); - const oldGroupDescriptor = this.groups.get(groupId); - if (oldGroupDescriptor !== undefined) { - oldGroupDescriptor.updateFromLockGroupMessage(lockGroupMessage); - this.notifyLockGroup(lockGroupMessage); - } } else if (message.hasUserleftzonemessage()) { const userLeftMessage = message.getUserleftzonemessage() as UserLeftZoneMessage; this.users.delete(userLeftMessage.getUserid()); @@ -256,9 +242,6 @@ export class Zone { } else if (message.hasEmoteeventmessage()) { const emoteEventMessage = message.getEmoteeventmessage() as EmoteEventMessage; this.notifyEmote(emoteEventMessage); - } else if (message.hasLockgroupmessage()) { - const lockGroupMessage = message.getLockgroupmessage() as LockGroupMessage; - this.notifyLockGroup(lockGroupMessage); } else if (message.hasPlayerdetailsupdatedmessage()) { const playerDetailsUpdatedMessage = message.getPlayerdetailsupdatedmessage() as PlayerDetailsUpdatedMessage; @@ -369,12 +352,6 @@ export class Zone { } } - private notifyLockGroup(lockGroupMessage: LockGroupMessage) { - for (const listener of this.listeners) { - this.socketListener.onLockGroup(lockGroupMessage, listener); - } - } - private notifyPlayerDetailsUpdated(playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage) { for (const listener of this.listeners) { if (listener.userId === playerDetailsUpdatedMessage.getUserid()) { diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index 436ecd39..f6e2feb0 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -38,7 +38,6 @@ import { ErrorMessage, WorldFullMessage, PlayerDetailsUpdatedMessage, - LockGroupMessage, LockGroupPromptMessage, } from "../Messages/generated/messages_pb"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; @@ -307,13 +306,6 @@ export class SocketManager implements ZoneEventListener { emitInBatch(listener, subMessage); } - onLockGroup(lockGroupMessage: LockGroupMessage, listener: ExSocketInterface): void { - const subMessage = new SubMessage(); - subMessage.setLockgroupmessage(lockGroupMessage); - - emitInBatch(listener, subMessage); - } - onPlayerDetailsUpdated( playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ExSocketInterface From 767e3b94e3026088db18d4e1537c7e79b646eb62 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Thu, 10 Mar 2022 13:19:23 +0100 Subject: [PATCH 16/33] fix compilation error --- back/src/Services/SocketManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index d0151e30..087843b1 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -903,7 +903,7 @@ export class SocketManager { } } - handleLockGroupMessage(room: GameRoom, user: User, message: LockGroupPromptMessage) { + handleLockGroupPromptMessage(room: GameRoom, user: User, message: LockGroupPromptMessage) { const group = user.group; if (!group) { return; From a8cd37bcf9a02936faec07945520fd9cb50d5388 Mon Sep 17 00:00:00 2001 From: Hanusiak Piotr Date: Thu, 10 Mar 2022 15:34:19 +0100 Subject: [PATCH 17/33] well-known values wip --- messages/protos/messages.proto | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 78858499..9d211855 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "google/protobuf/wrappers.proto"; + /*********** PARTIAL MESSAGES **************/ message PositionMessage { @@ -362,9 +364,9 @@ message UserLeftZoneMessage { message GroupUpdateZoneMessage { int32 groupId = 1; PointMessage position = 2; - int32 groupSize = 3; + google.protobuf.UInt32Value groupSize = 3; Zone fromZone = 4; - bool locked = 5; + google.protobuf.BoolValue locked = 5; } message GroupLeftZoneMessage { From 0e7a52aa58d009fd30d455fc0f4ee5e9e9c9269c Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 17 Mar 2022 10:38:52 +0100 Subject: [PATCH 18/33] update with dan suggest Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 2 +- front/src/Url/UrlManager.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 422f6546..c8c67b77 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -129,7 +129,7 @@ class ConnectionManager { } urlManager.pushRoomIdToUrl(this._currentRoom); } else if (connexionType === GameConnexionTypes.privateAccessToken) { - const organizationMemberToken = urlManager.getPrivateAccessToken; + const organizationMemberToken = urlManager.privateAccessToken; //clear queryPrivateAccessToken query in window location urlParams.delete(queryPrivateAccessToken); diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index f1283f70..5ab6ba21 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -40,7 +40,7 @@ class UrlManager { /** * @return string */ - get getPrivateAccessToken(): string | null { + get privateAccessToken(): string | null { const urlParams = new URLSearchParams(window.location.search.toString()); return urlParams.get(queryPrivateAccessToken); } From 56fb73c6822e5c9dd4150e23fd3641a2e39091b3 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Thu, 17 Mar 2022 10:53:56 +0100 Subject: [PATCH 19/33] Change roomId by playUri Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 2 +- pusher/src/Services/AdminApi.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index c8c67b77..d2b8275e 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -144,7 +144,7 @@ class ConnectionManager { 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.localUser = new LocalUser(data.userUuid, data.email); this.authToken = data.authToken; localUserStore.saveUser(this.localUser); localUserStore.setAuthToken(this.authToken); diff --git a/pusher/src/Services/AdminApi.ts b/pusher/src/Services/AdminApi.ts index 62d582ff..33c8ad93 100644 --- a/pusher/src/Services/AdminApi.ts +++ b/pusher/src/Services/AdminApi.ts @@ -65,7 +65,7 @@ class AdminApi { const res = await Axios.get>(ADMIN_API_URL + "/api/room/access", { params: { userIdentifier, - roomId: playUri, + playUri, ipAddress, characterLayers, }, From 29a0b9c5ae7d8ca4085bbedcbf14d9ca7e634135 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Sat, 19 Mar 2022 07:11:15 +0100 Subject: [PATCH 20/33] Refactor access by token Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 38 +----------------------- front/src/Url/UrlManager.ts | 22 ++++---------- 2 files changed, 6 insertions(+), 54 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index d2b8275e..643ab57d 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -2,7 +2,7 @@ import Axios from "axios"; import { PUSHER_URL } from "../Enum/EnvironmentVariable"; import { RoomConnection } from "./RoomConnection"; import type { OnConnectInterface, PositionInterface, ViewportInterface } from "./ConnexionModels"; -import { GameConnexionTypes, queryPrivateAccessToken, urlManager } from "../Url/UrlManager"; +import { GameConnexionTypes, urlManager } from "../Url/UrlManager"; import { localUserStore } from "./LocalUserStore"; import { CharacterTexture, LocalUser } from "./LocalUser"; import { Room } from "./Room"; @@ -128,42 +128,6 @@ class ConnectionManager { return Promise.reject(new Error("You will be redirect on login page")); } urlManager.pushRoomIdToUrl(this._currentRoom); - } else if (connexionType === GameConnexionTypes.privateAccessToken) { - const organizationMemberToken = urlManager.privateAccessToken; - - //clear queryPrivateAccessToken query in window location - urlParams.delete(queryPrivateAccessToken); - - //create play uri parameter - const playUri = window.location.protocol + "//" + window.location.host + window.location.pathname; - const data = await Axios.post(`${PUSHER_URL}/register`, { - organizationMemberToken, - playUri, - }).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.email); - this.authToken = data.authToken; - localUserStore.saveUser(this.localUser); - localUserStore.setAuthToken(this.authToken); - analyticsClient.loggedWithToken(); - - const roomUrl = data.roomUrl; - - const query = urlParams.toString(); - this._currentRoom = await Room.createRoom( - new URL( - window.location.protocol + - "//" + - window.location.host + - roomUrl + - (query ? "?" + query : "") + //use urlParams because the token param must be deleted - window.location.hash - ) - ); - urlManager.pushRoomIdToUrl(this._currentRoom); } //@deprecated else if (connexionType === GameConnexionTypes.register) { diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index 5ab6ba21..a7abbadd 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -6,28 +6,24 @@ export enum GameConnexionTypes { register /*@deprecated*/, empty, unknown, - jwt, + jwt /*@deprecated*/, login, - privateAccessToken, } -export const queryPrivateAccessToken = "privateAccessToken"; - //this class is responsible with analysing and editing the game's url class UrlManager { public getGameConnexionType(): GameConnexionTypes { const url = window.location.pathname.toString(); if (url === "/login") { return GameConnexionTypes.login; - } else if (url === "/jwt") { + } + //@deprecated jwt url will be replace by "?token=" + else if (url === "/jwt") { return GameConnexionTypes.jwt; } else if (url.includes("_/") || url.includes("*/") || url.includes("@/")) { - if (window.location.search.includes(queryPrivateAccessToken)) { - return GameConnexionTypes.privateAccessToken; - } return GameConnexionTypes.room; } - //@deprecated register url will be replace by "?privateAccessToken=" + //@deprecated register url will be replace by "?token=" else if (url.includes("register/")) { return GameConnexionTypes.register; } else if (url === "/") { @@ -37,14 +33,6 @@ class UrlManager { } } - /** - * @return string - */ - get privateAccessToken(): string | null { - const urlParams = new URLSearchParams(window.location.search.toString()); - return urlParams.get(queryPrivateAccessToken); - } - /** * @deprecated */ From e618dc6c3d99079fb205688f21a026da6a3b733b Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Sun, 20 Mar 2022 14:33:25 +0100 Subject: [PATCH 21/33] Refactor connexion manager Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 14 +++++++------- pusher/src/Controller/OpenIdProfileController.ts | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 643ab57d..38be8737 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -85,8 +85,7 @@ class ConnectionManager { * Tries to login to the node server and return the starting map url to be loaded */ public async initGameConnexion(): Promise { - const connexionType = urlManager.getGameConnexionType(); - this.connexionType = connexionType; + this.connexionType = urlManager.getGameConnexionType(); this._currentRoom = null; const urlParams = new URLSearchParams(window.location.search); @@ -99,13 +98,14 @@ class ConnectionManager { urlParams.delete("token"); } - if (connexionType === GameConnexionTypes.login) { + if (this.connexionType === GameConnexionTypes.login) { this._currentRoom = await Room.createRoom(new URL(localUserStore.getLastRoomUrl())); if (this.loadOpenIDScreen() !== null) { return Promise.reject(new Error("You will be redirect on login page")); } urlManager.pushRoomIdToUrl(this._currentRoom); - } else if (connexionType === GameConnexionTypes.jwt) { + } else if (this.connexionType === GameConnexionTypes.jwt) { + /** @deprecated */ if (!token) { const code = urlParams.get("code"); const state = urlParams.get("state"); @@ -130,7 +130,7 @@ class ConnectionManager { urlManager.pushRoomIdToUrl(this._currentRoom); } //@deprecated - else if (connexionType === GameConnexionTypes.register) { + else if (this.connexionType === GameConnexionTypes.register) { const organizationMemberToken = urlManager.getOrganizationToken(); const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then( (res) => res.data @@ -159,11 +159,11 @@ class ConnectionManager { ) ); urlManager.pushRoomIdToUrl(this._currentRoom); - } else if (connexionType === GameConnexionTypes.room || connexionType === GameConnexionTypes.empty) { + } else if (this.connexionType === GameConnexionTypes.room || this.connexionType === GameConnexionTypes.empty) { this.authToken = localUserStore.getAuthToken(); let roomPath: string; - if (connexionType === GameConnexionTypes.empty) { + if (this.connexionType === GameConnexionTypes.empty) { roomPath = localUserStore.getLastRoomUrl(); //get last room path from cache api try { diff --git a/pusher/src/Controller/OpenIdProfileController.ts b/pusher/src/Controller/OpenIdProfileController.ts index 3ff4c948..e0b77268 100644 --- a/pusher/src/Controller/OpenIdProfileController.ts +++ b/pusher/src/Controller/OpenIdProfileController.ts @@ -13,14 +13,14 @@ export class OpenIdProfileController extends BaseHttpController { } try { const resCheckTokenAuth = await openIDClient.checkTokenAuth(accessToken as string); - if (!resCheckTokenAuth.email) { + if (!resCheckTokenAuth.sub) { throw new Error("Email was not found"); } res.send( this.buildHtml( OPID_CLIENT_ISSUER, - resCheckTokenAuth.email as string, - resCheckTokenAuth.picture as string | undefined + resCheckTokenAuth.sub as string + /*resCheckTokenAuth.picture as string | undefined*/ ) ); return; From 1b2c67a4d7fd2054dd51592bfd328184ce7359db Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Mon, 28 Mar 2022 13:47:02 +0200 Subject: [PATCH 22/33] removed obsolete console.log --- front/src/Phaser/Game/GameScene.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index bc02cf87..1ef034dd 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -2038,7 +2038,6 @@ ${escapedMessage} } private doShareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface) { - console.log(groupPositionMessage); //delete previous group this.doDeleteGroup(groupPositionMessage.groupId); From 6230bb16574cf92d9558a25be485586ecb805c90 Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Mon, 28 Mar 2022 14:35:21 +0200 Subject: [PATCH 23/33] fix linter issues --- back/src/Services/SocketManager.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index 2d3dd2e3..8aa7f6a4 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -287,7 +287,9 @@ export class SocketManager { this.onClientLeave(thing, newZone, listener), (emoteEventMessage: EmoteEventMessage, listener: ZoneSocket) => this.onEmote(emoteEventMessage, listener), - (groupId: number, listener: ZoneSocket) => this.onLockGroup(groupId, listener, roomPromise), + (groupId: number, listener: ZoneSocket) => { + void this.onLockGroup(groupId, listener, roomPromise); + }, (playerDetailsUpdatedMessage: PlayerDetailsUpdatedMessage, listener: ZoneSocket) => this.onPlayerDetailsUpdated(playerDetailsUpdatedMessage, listener) ) @@ -391,7 +393,11 @@ export class SocketManager { emitZoneMessage(subMessage, client); } - private async onLockGroup(groupId: number, client: ZoneSocket, roomPromise: PromiseLike | undefined) { + private async onLockGroup( + groupId: number, + client: ZoneSocket, + roomPromise: PromiseLike | undefined + ): Promise { if (!roomPromise) { return; } From 82dffff5a750d676b9bfabb016f60b4f3f63ec40 Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Mon, 28 Mar 2022 17:08:12 +0200 Subject: [PATCH 24/33] make use of proto well knows types --- front/src/Connexion/RoomConnection.ts | 2 +- front/src/Network/ProtobufClientUtils.ts | 2 +- messages/package.json | 2 +- messages/protos/messages.proto | 6 ++++-- pusher/src/Model/Zone.ts | 13 +++++++++---- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index f1dbde13..5cfc85c1 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -41,7 +41,7 @@ import { SetPlayerDetailsMessage as SetPlayerDetailsMessageTsProto, PingMessage as PingMessageTsProto, CharacterLayerMessage, -} from "../Messages/ts-proto-generated/messages"; +} from "../Messages/ts-proto-generated/protos/messages"; import { Subject } from "rxjs"; import { selectCharacterSceneVisibleStore } from "../Stores/SelectCharacterStore"; import { gameManager } from "../Phaser/Game/GameManager"; diff --git a/front/src/Network/ProtobufClientUtils.ts b/front/src/Network/ProtobufClientUtils.ts index 3e172d0f..beec3d9f 100644 --- a/front/src/Network/ProtobufClientUtils.ts +++ b/front/src/Network/ProtobufClientUtils.ts @@ -1,4 +1,4 @@ -import { PositionMessage, PositionMessage_Direction } from "../Messages/ts-proto-generated/messages"; +import { PositionMessage, PositionMessage_Direction } from "../Messages/ts-proto-generated/protos/messages"; import type { PointInterface } from "../Connexion/ConnexionModels"; diff --git a/messages/package.json b/messages/package.json index 644065c9..4cef28dd 100644 --- a/messages/package.json +++ b/messages/package.json @@ -6,7 +6,7 @@ "proto": "grpc_tools_node_protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --grpc_out=generated --js_out=\"import_style=commonjs,binary:generated\" --ts_out=generated -I ./protos protos/*.proto", "ts-proto": "grpc_tools_node_protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=ts-proto-generated --ts_proto_opt=oneof=unions --ts_proto_opt=esModuleInterop=true protos/*.proto", "copy-to-back": "rm -rf ../back/src/Messages/generated && cp -rf generated/ ../back/src/Messages/generated", - "copy-to-front-ts-proto": "sed 's/import { Observable } from \"rxjs\";/import type { Observable } from \"rxjs\";/g' ts-proto-generated/protos/messages.ts > ../front/src/Messages/ts-proto-generated/messages.ts", + "copy-to-front-ts-proto": "cp -rf ts-proto-generated/* ../front/src/Messages/ts-proto-generated/ && sed -i 's/import { Observable } from \"rxjs\";/import type { Observable } from \"rxjs\";/g' ../front/src/Messages/ts-proto-generated/protos/messages.ts", "copy-to-pusher": "rm -rf ../pusher/src/Messages/generated && cp -rf generated/ ../pusher/src/Messages/generated", "json-copy-to-pusher": "rm -rf ../pusher/src/Messages/JsonMessages/* && cp -rf JsonMessages/* ../pusher/src/Messages/JsonMessages/", "json-copy-to-back": "rm -rf ../back/src/Messages/JsonMessages/* && cp -rf JsonMessages/* ../back/src/Messages/JsonMessages/", diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 4ddb3941..35db5321 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "google/protobuf/wrappers.proto"; + /*********** PARTIAL MESSAGES **************/ message PositionMessage { @@ -189,8 +191,8 @@ message BatchMessage { message GroupUpdateMessage { int32 groupId = 1; PointMessage position = 2; - int32 groupSize = 3; - bool locked = 4; + google.protobuf.UInt32Value groupSize = 3; + google.protobuf.BoolValue locked = 4; } message GroupDeleteMessage { diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index 02a01d8d..f3b15ed2 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -22,6 +22,7 @@ import { import { ClientReadableStream } from "grpc"; import { PositionDispatcher } from "_Model/PositionDispatcher"; import Debug from "debug"; +import { BoolValue, UInt32Value } from "google-protobuf/google/protobuf/wrappers_pb"; const debug = Debug("zone"); @@ -125,9 +126,9 @@ export class UserDescriptor { export class GroupDescriptor { private constructor( public readonly groupId: number, - private groupSize: number, + private groupSize: number | undefined, private position: PointMessage, - private locked: boolean + private locked: boolean | undefined ) {} public static createFromGroupUpdateZoneMessage(message: GroupUpdateZoneMessage): GroupDescriptor { @@ -150,9 +151,13 @@ export class GroupDescriptor { throw new Error("GroupDescriptor.groupId is not an integer: " + this.groupId); } groupUpdateMessage.setGroupid(this.groupId); - groupUpdateMessage.setGroupsize(this.groupSize); + if (this.groupSize !== undefined) { + groupUpdateMessage.setGroupsize(new UInt32Value().setValue(this.groupSize)); + } groupUpdateMessage.setPosition(this.position); - groupUpdateMessage.setLocked(this.locked); + if (this.locked !== undefined) { + groupUpdateMessage.setLocked(new BoolValue().setValue(this.locked)); + } return groupUpdateMessage; } } From 225f80b3ad3de6d2ed02428f135946698bdcc79e Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Tue, 29 Mar 2022 10:00:26 +0200 Subject: [PATCH 25/33] fixed types for RoomConnection --- front/src/Connexion/AdminMessagesService.ts | 2 +- front/src/Connexion/ConnexionModels.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/front/src/Connexion/AdminMessagesService.ts b/front/src/Connexion/AdminMessagesService.ts index 4b7030ed..22bdd469 100644 --- a/front/src/Connexion/AdminMessagesService.ts +++ b/front/src/Connexion/AdminMessagesService.ts @@ -1,5 +1,5 @@ import { Subject } from "rxjs"; -import type { BanUserMessage, SendUserMessage } from "../Messages/ts-proto-generated/messages"; +import type { BanUserMessage, SendUserMessage } from "../Messages/ts-proto-generated/protos/messages"; export enum AdminMessageEventTypes { admin = "message", diff --git a/front/src/Connexion/ConnexionModels.ts b/front/src/Connexion/ConnexionModels.ts index d71d5c63..84ce60c1 100644 --- a/front/src/Connexion/ConnexionModels.ts +++ b/front/src/Connexion/ConnexionModels.ts @@ -43,8 +43,8 @@ export interface PositionInterface { export interface GroupCreatedUpdatedMessageInterface { position: PositionInterface; groupId: number; - groupSize: number; - locked: boolean; + groupSize?: number; + locked?: boolean; } export interface GroupUsersUpdateMessageInterface { From 0e3529ae4a3e430849ad65654872148f33a6def5 Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Tue, 29 Mar 2022 11:04:29 +0200 Subject: [PATCH 26/33] fix locking bubble when returning from away mode --- front/src/Phaser/Game/GameScene.ts | 10 ++-------- front/src/Stores/CurrentPlayerGroupStore.ts | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 1ef034dd..66a2d8eb 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -76,7 +76,7 @@ import { userIsAdminStore } from "../../Stores/GameStore"; import { contactPageStore } from "../../Stores/MenuStore"; import type { WasCameraUpdatedEvent } from "../../Api/Events/WasCameraUpdatedEvent"; import { audioManagerFileStore } from "../../Stores/AudioManagerStore"; -import { currentPlayerGroupIdStore, currentPlayerGroupLockStateStore } from "../../Stores/CurrentPlayerGroupStore"; +import { currentPlayerGroupLockStateStore } from "../../Stores/CurrentPlayerGroupStore"; import EVENT_TYPE = Phaser.Scenes.Events; import Texture = Phaser.Textures.Texture; @@ -711,10 +711,6 @@ export class GameScene extends DirtyScene { } }); - this.currentPlayerGroupIdStoreUnsubscribe = currentPlayerGroupIdStore.subscribe((groupId) => { - this.currentPlayerGroupId = groupId; - }); - Promise.all([ this.connectionAnswerPromiseDeferred.promise as Promise, ...scriptPromises, @@ -847,8 +843,7 @@ export class GameScene extends DirtyScene { }); this.connection.groupUsersUpdateMessageStream.subscribe((message) => { - // TODO: how else can we deduce our current group? - currentPlayerGroupIdStore.set(message.groupId); + this.currentPlayerGroupId = message.groupId; }); /** @@ -1870,7 +1865,6 @@ ${escapedMessage} break; case "DeleteGroupEvent": { this.doDeleteGroup(event.groupId); - currentPlayerGroupIdStore.set(undefined); currentPlayerGroupLockStateStore.set(undefined); break; } diff --git a/front/src/Stores/CurrentPlayerGroupStore.ts b/front/src/Stores/CurrentPlayerGroupStore.ts index cda46325..91d4b50e 100644 --- a/front/src/Stores/CurrentPlayerGroupStore.ts +++ b/front/src/Stores/CurrentPlayerGroupStore.ts @@ -1,4 +1,3 @@ import { writable } from "svelte/store"; -export const currentPlayerGroupIdStore = writable(undefined); export const currentPlayerGroupLockStateStore = writable(undefined); From c1222c1c571d3a10ac62c873002c825c9cf42517 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Tue, 29 Mar 2022 13:45:31 +0200 Subject: [PATCH 27/33] Fix run pretty Signed-off-by: Gregoire Parant --- front/src/Connexion/ConnectionManager.ts | 2 +- pusher/src/Controller/OpenIdProfileController.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index c36f6fa8..c0c9597c 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -109,7 +109,7 @@ class ConnectionManager { } urlManager.pushRoomIdToUrl(this._currentRoom); } else if (this.connexionType === GameConnexionTypes.jwt) { - /** @deprecated */ + /** @deprecated */ if (!token) { const code = urlParams.get("code"); const state = urlParams.get("state"); diff --git a/pusher/src/Controller/OpenIdProfileController.ts b/pusher/src/Controller/OpenIdProfileController.ts index e0b77268..589c9d54 100644 --- a/pusher/src/Controller/OpenIdProfileController.ts +++ b/pusher/src/Controller/OpenIdProfileController.ts @@ -19,7 +19,7 @@ export class OpenIdProfileController extends BaseHttpController { res.send( this.buildHtml( OPID_CLIENT_ISSUER, - resCheckTokenAuth.sub as string + resCheckTokenAuth.sub /*resCheckTokenAuth.picture as string | undefined*/ ) ); From ac9926b8d69e6ff0845aff1665d04a5c8776342f Mon Sep 17 00:00:00 2001 From: Piotr 'pwh' Hanusiak Date: Mon, 28 Mar 2022 15:27:29 +0200 Subject: [PATCH 28/33] prevent actions menu from appearing when inserting space key on chat --- front/src/Phaser/UserInput/UserInputManager.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/front/src/Phaser/UserInput/UserInputManager.ts b/front/src/Phaser/UserInput/UserInputManager.ts index e7f814b9..b454de56 100644 --- a/front/src/Phaser/UserInput/UserInputManager.ts +++ b/front/src/Phaser/UserInput/UserInputManager.ts @@ -280,6 +280,9 @@ export class UserInputManager { ); this.scene.input.keyboard.on("keyup-SPACE", (event: Event) => { + if (this.isInputDisabled) { + return; + } this.userInputHandler.handleSpaceKeyUpEvent(event); }); } From f04cfb3bb44428badfb2e2314ef10ad0aeade652 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:23 +0000 Subject: [PATCH 29/33] Bump ansi-regex from 4.1.0 to 4.1.1 in /maps Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] --- maps/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/maps/yarn.lock b/maps/yarn.lock index 38a0f92b..97e22592 100644 --- a/maps/yarn.lock +++ b/maps/yarn.lock @@ -124,9 +124,9 @@ ansi-escapes@^4.2.1: type-fest "^0.21.3" ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-regex@^5.0.0: version "5.0.1" From 80122a52940ed0f34fcce9b0b7dbddc38eaf6ea6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:25 +0000 Subject: [PATCH 30/33] Bump minimist from 1.2.5 to 1.2.6 in /desktop/local-app Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] --- desktop/local-app/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop/local-app/yarn.lock b/desktop/local-app/yarn.lock index 03b6bbab..52bbce0a 100644 --- a/desktop/local-app/yarn.lock +++ b/desktop/local-app/yarn.lock @@ -587,9 +587,9 @@ minimatch@^3.0.4: brace-expansion "^1.1.7" minimist@^1.2.0, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + version "1.2.6" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" + integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== mkdirp@^0.5.1: version "0.5.5" From f436f5bcd4765505b7eccbeea9362af8625f46d7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:30 +0000 Subject: [PATCH 31/33] Bump ansi-regex from 4.1.0 to 4.1.1 in /desktop/electron Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] --- desktop/electron/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop/electron/yarn.lock b/desktop/electron/yarn.lock index 82034d10..179d7ff3 100644 --- a/desktop/electron/yarn.lock +++ b/desktop/electron/yarn.lock @@ -295,9 +295,9 @@ ansi-escapes@^4.2.1: type-fest "^0.21.3" ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-regex@^5.0.1: version "5.0.1" From 8d690bcae1f0a1037111adfd8943dde81ecf210b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:34 +0000 Subject: [PATCH 32/33] Bump ansi-regex from 4.1.0 to 4.1.1 in /uploader Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] --- uploader/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uploader/yarn.lock b/uploader/yarn.lock index feab6ff4..4c36556a 100644 --- a/uploader/yarn.lock +++ b/uploader/yarn.lock @@ -174,9 +174,9 @@ ansi-escapes@^4.2.1: type-fest "^0.11.0" ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-regex@^5.0.0: version "5.0.0" From ba68623e6f807b7046e79be51b7bb4384e4a7fd4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 12:41:59 +0000 Subject: [PATCH 33/33] Bump plist from 3.0.4 to 3.0.5 in /desktop/electron Bumps [plist](https://github.com/TooTallNate/node-plist) from 3.0.4 to 3.0.5. - [Release notes](https://github.com/TooTallNate/node-plist/releases) - [Changelog](https://github.com/TooTallNate/plist.js/blob/master/History.md) - [Commits](https://github.com/TooTallNate/node-plist/commits) --- updated-dependencies: - dependency-name: plist dependency-type: indirect ... Signed-off-by: dependabot[bot] --- desktop/electron/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desktop/electron/yarn.lock b/desktop/electron/yarn.lock index 179d7ff3..32dd7fe9 100644 --- a/desktop/electron/yarn.lock +++ b/desktop/electron/yarn.lock @@ -2409,9 +2409,9 @@ pirates@^4.0.1: integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ== plist@^3.0.1, plist@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.4.tgz#a62df837e3aed2bb3b735899d510c4f186019cbe" - integrity sha512-ksrr8y9+nXOxQB2osVNqrgvX/XQPOXaU4BQMKjYq8PvaY1U18mo+fKgBSwzK+luSyinOuPae956lSVcBwxlAMg== + version "3.0.5" + resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.5.tgz#2cbeb52d10e3cdccccf0c11a63a85d830970a987" + integrity sha512-83vX4eYdQp3vP9SxuYgEM/G/pJQqLUz/V/xzPrzruLs7fz7jxGQ1msZ/mg1nwZxUSuOp4sb+/bEIbRrbzZRxDA== dependencies: base64-js "^1.5.1" xmlbuilder "^9.0.7"