From 8c5c680cfbcf3a84c0e5dab260c4d5256f7498bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Sat, 16 Apr 2022 11:36:10 +0200 Subject: [PATCH] Adding a new "jitsiNoPrefix" property. When set to "true", WorkAdventure will NOT prefix the Jitsi room name with a hash, gicing full control to the user over the Jitsi room name. --- docs/maps/meeting-rooms.md | 14 +++++++++++++- front/src/Phaser/Game/GameMapProperties.ts | 1 + front/src/Phaser/Game/GameMapPropertiesListener.ts | 6 +++++- front/src/WebRtc/JitsiFactory.ts | 4 ++-- maps/tests/jitsi_config.json | 13 +++++++++---- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/docs/maps/meeting-rooms.md b/docs/maps/meeting-rooms.md index 9c3963ed..bab732a5 100644 --- a/docs/maps/meeting-rooms.md +++ b/docs/maps/meeting-rooms.md @@ -10,7 +10,7 @@ On your map, you can define special zones (meeting rooms) that will trigger the In order to create Jitsi meet zones: * You must create a specific layer. -* In layer properties, you MUST add a "`jitsiRoom`" property (of type "`string`"). The value of the property is the name of the room in Jitsi. Note: the name of the room will be "slugified" and prepended with the name of the instance of the map (so that different instances of the map have different rooms) +* In layer properties, you MUST add a "`jitsiRoom`" property (of type "`string`"). The value of the property is the name of the room in Jitsi. Note: the name of the room will be "slugified" and prepended with a hash of the room URL * You may also use "jitsiWidth" property (of type "number" between 0 and 100) to control the width of the iframe containing the meeting room. You can have this layer (i.e. your meeting area) to be selectable as the precise location for your meeting using the [Google Calendar integration for Work Adventure](/integrations/google-calendar). To do so, you must set the `meetingRoomLabel` property. You can provide any name that you would like your meeting room to have (as a string). @@ -82,3 +82,15 @@ and not {.alert.alert-info} When you use `jitsiUrl`, the targeted Jitsi instance must be public. You cannot use moderation features or the JWT tokens authentication with maps configured using the `jitsiUrl` property. + +## Full control over the Jitsi room name + +By default, the name of the room will be "slugified" and prepended with a hash of the room URL. +This is what you want most of the time. Indeed, different maps with the same Jitsi room name (the same `jitsiRoom` property) will not share the same Jitsi room instance. + +However, sometimes, you may actually want to have different WorkAdventure meeting rooms that are actually sharing +the same Jitsi meet meeting room. Or if you are pointing to a custom Jitsi server (using the `jitsiUrl` property), +you may want to point to a specific existing room. + +For all those use cases, you can use `jitsiNoPrefix: true`. This will remove the automatic prefixing +of the hash and will give you full control on the Jitsi room name. diff --git a/front/src/Phaser/Game/GameMapProperties.ts b/front/src/Phaser/Game/GameMapProperties.ts index b77bd02b..f25ea4b3 100644 --- a/front/src/Phaser/Game/GameMapProperties.ts +++ b/front/src/Phaser/Game/GameMapProperties.ts @@ -15,6 +15,7 @@ export enum GameMapProperties { JITSI_TRIGGER_MESSAGE = "jitsiTriggerMessage", JITSI_URL = "jitsiUrl", JITSI_WIDTH = "jitsiWidth", + JITSI_NO_PREFIX = "jitsiNoPrefix", NAME = "name", OPEN_TAB = "openTab", OPEN_WEBSITE = "openWebsite", diff --git a/front/src/Phaser/Game/GameMapPropertiesListener.ts b/front/src/Phaser/Game/GameMapPropertiesListener.ts index 449e8708..de6bdefe 100644 --- a/front/src/Phaser/Game/GameMapPropertiesListener.ts +++ b/front/src/Phaser/Game/GameMapPropertiesListener.ts @@ -67,7 +67,11 @@ export class GameMapPropertiesListener { }); } else { const openJitsiRoomFunction = () => { - const roomName = jitsiFactory.getRoomName(newValue.toString(), this.scene.roomUrl); + let addPrefix = true; + if (allProps.get(GameMapProperties.JITSI_NO_PREFIX)) { + addPrefix = false; + } + const roomName = jitsiFactory.getRoomName(newValue.toString(), this.scene.roomUrl, addPrefix); const jitsiUrl = allProps.get(GameMapProperties.JITSI_URL) as string | undefined; if (JITSI_PRIVATE_MODE && !jitsiUrl) { diff --git a/front/src/WebRtc/JitsiFactory.ts b/front/src/WebRtc/JitsiFactory.ts index c8824f0e..62800888 100644 --- a/front/src/WebRtc/JitsiFactory.ts +++ b/front/src/WebRtc/JitsiFactory.ts @@ -136,8 +136,8 @@ class JitsiFactory { /** * Slugifies the room name and prepends the room name with the instance */ - public getRoomName(roomName: string, roomId: string): string { - return slugify(StringUtils.shortHash(roomId) + "-" + roomName); + public getRoomName(roomName: string, roomId: string, addPrefix: boolean): string { + return slugify((addPrefix ? StringUtils.shortHash(roomId) + "-" : "") + roomName); } public start( diff --git a/maps/tests/jitsi_config.json b/maps/tests/jitsi_config.json index 9a812cc8..d0a446e1 100644 --- a/maps/tests/jitsi_config.json +++ b/maps/tests/jitsi_config.json @@ -43,6 +43,11 @@ "type":"string", "value":"{\"DEFAULT_BACKGROUND\":\"#77ee77\"}" }, + { + "name":"jitsiNoPrefix", + "type":"bool", + "value":true + }, { "name":"jitsiRoom", "type":"string", @@ -65,7 +70,7 @@ "name":"floorLayer", "objects":[ { - "height":83.6666666666666, + "height":110.891622876526, "id":1, "name":"", "rotation":0, @@ -73,14 +78,14 @@ { "fontfamily":"Sans Serif", "pixelsize":13, - "text":"Test:\nWalk on the carpet and press space\nResult:\nJitsi opens, background in green and audio\/video is muted", + "text":"Test:\nWalk on the carpet and press space\nResult:\nJitsi opens, background in green and audio\/video is muted.\nThe name of the room (displayed at the top of Jitsi) is \"Myroom Avec Espace EA\"", "wrap":true }, "type":"", "visible":true, "width":315.4375, - "x":2.28125, - "y":235.166666666667 + "x":1.48051599382768, + "y":209.535838407429 }], "opacity":1, "type":"objectgroup",