From 7f8cc76eb735da77012e0c939ed814143b120e2a Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Sun, 10 Jan 2021 17:03:05 +0100 Subject: [PATCH 01/19] front: fix webrtc webcam feed on Firefox Seems like Firefox doesn't support specifing both exact and ideal constraints... --- front/src/WebRtc/MediaManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/WebRtc/MediaManager.ts b/front/src/WebRtc/MediaManager.ts index 4aa240cd..6f78f283 100644 --- a/front/src/WebRtc/MediaManager.ts +++ b/front/src/WebRtc/MediaManager.ts @@ -13,7 +13,7 @@ if(localValueVideo){ let videoConstraint: boolean|MediaTrackConstraints = { width: { min: 640, ideal: 1280, max: 1920 }, height: { min: 400, ideal: 720 }, - frameRate: {exact: valueVideo, ideal: valueVideo}, + frameRate: { ideal: valueVideo }, facingMode: "user", resizeMode: 'crop-and-scale', aspectRatio: 1.777777778 From f431e769cc65f484241c036012939c1b7c8bd4a7 Mon Sep 17 00:00:00 2001 From: psy Date: Thu, 14 Jan 2021 11:45:14 +0100 Subject: [PATCH 02/19] add remote files and streams to playAudio --- front/src/Phaser/Game/GameScene.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index d25c2893..a6ec1662 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -599,7 +599,17 @@ export class GameScene extends ResizableScene implements CenterListener { audioManager.unloadAudio(); } else { const mapDirUrl = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/')); - const realAudioPath = mapDirUrl + '/' + url; + const audioPath = url as string; + let realAudioPath = ''; + + if (audioPath.indexOf('://') > 0) { + // remote file or stream + realAudioPath = audioPath; + } else { + // local file, include it relative to map directory + realAudioPath = mapDirUrl + '/' + url; + } + audioManager.loadAudio(realAudioPath); if (loop) { From 8d67947bc19db6a34a8552093e612b490bdcc6d9 Mon Sep 17 00:00:00 2001 From: psy Date: Thu, 14 Jan 2021 11:48:06 +0100 Subject: [PATCH 03/19] move map url to else case --- front/src/Phaser/Game/GameScene.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index a6ec1662..021a7c8b 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -598,7 +598,6 @@ export class GameScene extends ResizableScene implements CenterListener { if (url === undefined) { audioManager.unloadAudio(); } else { - const mapDirUrl = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/')); const audioPath = url as string; let realAudioPath = ''; @@ -607,9 +606,10 @@ export class GameScene extends ResizableScene implements CenterListener { realAudioPath = audioPath; } else { // local file, include it relative to map directory + const mapDirUrl = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/')); realAudioPath = mapDirUrl + '/' + url; } - + audioManager.loadAudio(realAudioPath); if (loop) { From e2f400472fd6576064be1035f50c8596f03a3b55 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Tue, 19 Jan 2021 10:46:53 +0100 Subject: [PATCH 04/19] Template google analytics data Without this patch, the index.html contains google analytics at all times, including for people self-hosting it. This is a problem for privacy reasons, and only people wanting to have analytics on their instances should be able to enable them. This fixes it by making sure the index.html page is templated to sideload content from ANALYTICS_CODE_PATH (which itself is also templated, for convenience). --- front/.gitignore | 3 ++- front/Dockerfile | 1 + front/dist/ga.html.tmpl | 9 ++++++++ front/dist/{index.html => index.html.tmpl} | 11 ++------- front/templater.sh | 26 ++++++++++++++++++++++ 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 front/dist/ga.html.tmpl rename front/dist/{index.html => index.html.tmpl} (95%) create mode 100755 front/templater.sh diff --git a/front/.gitignore b/front/.gitignore index e77b54d0..b6f01e2c 100644 --- a/front/.gitignore +++ b/front/.gitignore @@ -5,4 +5,5 @@ /dist/webpack.config.js /dist/webpack.config.js.map /dist/src -*.sh \ No newline at end of file +*.sh +!templater.sh diff --git a/front/Dockerfile b/front/Dockerfile index 6c79ad6e..b0d17877 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -11,5 +11,6 @@ COPY --from=builder --chown=docker:docker /var/www/messages/generated /var/www/h RUN yarn install ENV NODE_ENV=production +ENV STARTUP_COMMAND_0="./templater.sh" ENV STARTUP_COMMAND_1="yarn run build" ENV APACHE_DOCUMENT_ROOT=dist/ diff --git a/front/dist/ga.html.tmpl b/front/dist/ga.html.tmpl new file mode 100644 index 00000000..ace84b39 --- /dev/null +++ b/front/dist/ga.html.tmpl @@ -0,0 +1,9 @@ + + + diff --git a/front/dist/index.html b/front/dist/index.html.tmpl similarity index 95% rename from front/dist/index.html rename to front/dist/index.html.tmpl index 9a197822..a2b44788 100644 --- a/front/dist/index.html +++ b/front/dist/index.html.tmpl @@ -6,15 +6,8 @@ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> - - - + + diff --git a/front/templater.sh b/front/templater.sh new file mode 100755 index 00000000..aa6534b3 --- /dev/null +++ b/front/templater.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -x +set -o nounset errexit +template_file_index=dist/index.html.tmpl +generated_file_index=dist/index.html +tmp_trackcodefile=/tmp/trackcode + +# To inject tracking code, you have two choices: +# 1) Template using the provided google analytics +# 2) Insert with your own provided code, by overriding the ANALYTICS_CODE_PATH +# The ANALYTICS_CODE_PATH is the location of a file inside the container +ANALYTICS_CODE_PATH="${ANALYTICS_CODE_PATH:-dist/ga.html.tmpl}" + +if [[ "${INSERT_ANALYTICS:-NO}" == "NO" ]]; then + echo "" > "${tmp_trackcodefile}" +fi + +# Automatically insert analytics if TRACKING_NUMBER is set +if [[ "${TRACKING_NUMBER:-}" != "" || "${INSERT_ANALYTICS:-NO}" != "NO" ]]; then + echo "Templating code from ${ANALYTICS_CODE_PATH}" + sed "s##${TRACKING_NUMBER:-}#g" "${ANALYTICS_CODE_PATH}" > "$tmp_trackcodefile" +fi + +echo "Templating ${generated_file_index} from ${template_file_index}" +sed "//r ${tmp_trackcodefile}" "${template_file_index}" > "${generated_file_index}" +rm "${tmp_trackcodefile}" From b03abee4814881f0899533533115c4ec867dc08f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 20 Jan 2021 10:34:26 +0100 Subject: [PATCH 05/19] Fixing admin links --- deeployer.libsonnet | 2 +- docker-compose.yaml | 2 +- front/src/Enum/EnvironmentVariable.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 9e2e708a..ae205efe 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -72,7 +72,7 @@ "env": { "API_URL": "pusher."+url, "UPLOADER_URL": "uploader."+url, - "ADMIN_URL": "admin."+url, + "ADMIN_URL": url, "JITSI_URL": env.JITSI_URL, "SECRET_JITSI_KEY": env.SECRET_JITSI_KEY, "TURN_SERVER": "turn:coturn.workadventu.re:443,turns:coturn.workadventu.re:443", diff --git a/docker-compose.yaml b/docker-compose.yaml index 8f0ace1d..23fa58a4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -28,7 +28,7 @@ services: NODE_ENV: development API_URL: pusher.workadventure.localhost UPLOADER_URL: uploader.workadventure.localhost - ADMIN_URL: admin.workadventure.localhost + ADMIN_URL: workadventure.localhost STARTUP_COMMAND_1: yarn install TURN_SERVER: "turn:coturn.workadventu.re:443,turns:coturn.workadventu.re:443" TURN_USER: workadventure diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index 32b881eb..e5aa5deb 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -1,7 +1,7 @@ const DEBUG_MODE: boolean = process.env.DEBUG_MODE == "true"; const API_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.API_URL || "pusher.workadventure.localhost"); const UPLOADER_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.UPLOADER_URL || 'uploader.workadventure.localhost'); -const ADMIN_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.ADMIN_URL || "admin.workadventure.localhost"); +const ADMIN_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.ADMIN_URL || "workadventure.localhost"); const TURN_SERVER: string = process.env.TURN_SERVER || "turn:numb.viagenie.ca"; const TURN_USER: string = process.env.TURN_USER || 'g.parant@thecodingmachine.com'; const TURN_PASSWORD: string = process.env.TURN_PASSWORD || 'itcugcOHxle9Acqi$'; From fd89d54ed9e8d47ee1901851477c400f74ee72b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 20 Jan 2021 16:57:30 +0100 Subject: [PATCH 06/19] Adding GA tracking in test envs --- deeployer.libsonnet | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 8770ba6f..c49bb00e 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -78,7 +78,8 @@ "TURN_SERVER": "turn:coturn.workadventu.re:443,turns:coturn.workadventu.re:443", "TURN_USER": "workadventure", "TURN_PASSWORD": "WorkAdventure123", - "JITSI_PRIVATE_MODE": if env.SECRET_JITSI_KEY != '' then "true" else "false" + "JITSI_PRIVATE_MODE": if env.SECRET_JITSI_KEY != '' then "true" else "false", + "TRACKING_NUMBER": "UA-10196481-11" } }, "uploader": { From 15b3e87bd1488dadcec847f8f2f172e433156694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 20 Jan 2021 17:30:11 +0100 Subject: [PATCH 07/19] Renaming TRACKING_NUMBER to GA_TRACKING_ID --- front/templater.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/front/templater.sh b/front/templater.sh index aa6534b3..e63617c5 100755 --- a/front/templater.sh +++ b/front/templater.sh @@ -15,10 +15,10 @@ if [[ "${INSERT_ANALYTICS:-NO}" == "NO" ]]; then echo "" > "${tmp_trackcodefile}" fi -# Automatically insert analytics if TRACKING_NUMBER is set -if [[ "${TRACKING_NUMBER:-}" != "" || "${INSERT_ANALYTICS:-NO}" != "NO" ]]; then +# Automatically insert analytics if GA_TRACKING_ID is set +if [[ "${GA_TRACKING_ID:-}" != "" || "${INSERT_ANALYTICS:-NO}" != "NO" ]]; then echo "Templating code from ${ANALYTICS_CODE_PATH}" - sed "s##${TRACKING_NUMBER:-}#g" "${ANALYTICS_CODE_PATH}" > "$tmp_trackcodefile" + sed "s##${GA_TRACKING_ID:-}#g" "${ANALYTICS_CODE_PATH}" > "$tmp_trackcodefile" fi echo "Templating ${generated_file_index} from ${template_file_index}" From 9e469a4a8f99082383ef898d4470c2a0c01f3e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 20 Jan 2021 17:30:26 +0100 Subject: [PATCH 08/19] Removing Google Analytics tracking from test environments --- deeployer.libsonnet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deeployer.libsonnet b/deeployer.libsonnet index c49bb00e..83f102d3 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -79,7 +79,7 @@ "TURN_USER": "workadventure", "TURN_PASSWORD": "WorkAdventure123", "JITSI_PRIVATE_MODE": if env.SECRET_JITSI_KEY != '' then "true" else "false", - "TRACKING_NUMBER": "UA-10196481-11" + //"GA_TRACKING_ID": "UA-10196481-11" } }, "uploader": { From f87f3889df05c8ddd2e76500d79392b2e8456911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Wed, 20 Jan 2021 17:36:50 +0100 Subject: [PATCH 09/19] Running templater in CI phase --- .github/workflows/continuous_integration.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 47b28d72..8072e606 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -39,6 +39,10 @@ jobs: run: yarn run proto && yarn run copy-to-front working-directory: "messages" + - name: "Create index.html" + run: ./templater.sh + working-directory: "front" + - name: "Build" run: yarn run build env: From 14b328c733941da18dc9450ed26ce662f9d118cf Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Thu, 7 Jan 2021 12:15:33 +0100 Subject: [PATCH 10/19] Removed hard coded default map You can apply local maps using the maps vhost as previously. But it's also possible to specify external maps by prepending http or https. --- .env.template | 1 + docker-compose.yaml | 1 + front/src/Connexion/ConnectionManager.ts | 10 ++++++---- front/src/Enum/EnvironmentVariable.ts | 2 ++ front/webpack.config.js | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.env.template b/.env.template index d0db42e3..ce3937d3 100644 --- a/.env.template +++ b/.env.template @@ -5,3 +5,4 @@ JITSI_PRIVATE_MODE=false JITSI_ISS= SECRET_JITSI_KEY= ADMIN_API_TOKEN=123 +START_ROOM_URL=/Floor0/floor0.json \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 23fa58a4..36d51c92 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -33,6 +33,7 @@ services: TURN_SERVER: "turn:coturn.workadventu.re:443,turns:coturn.workadventu.re:443" TURN_USER: workadventure TURN_PASSWORD: WorkAdventure123 + START_ROOM_URL: "$START_ROOM_URL" command: yarn run start volumes: - ./front:/usr/src/app diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index 12595f9d..b7788536 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -1,5 +1,5 @@ import Axios from "axios"; -import {API_URL} from "../Enum/EnvironmentVariable"; +import {API_URL, START_ROOM_URL} from "../Enum/EnvironmentVariable"; import {RoomConnection} from "./RoomConnection"; import {OnConnectInterface, PositionInterface, ViewportInterface} from "./ConnexionModels"; import {GameConnexionTypes, urlManager} from "../Url/UrlManager"; @@ -7,8 +7,6 @@ import {localUserStore} from "./LocalUserStore"; import {LocalUser} from "./LocalUser"; import {Room} from "./Room"; -const URL_ROOM_STARTED = 'tcm/workadventure/floor0'; - class ConnectionManager { private localUser!:LocalUser; @@ -50,7 +48,11 @@ class ConnectionManager { } let roomId: string if (connexionType === GameConnexionTypes.empty) { - roomId = urlManager.editUrlForRoom(URL_ROOM_STARTED, null, null); + if (START_ROOM_URL.startsWith('http://') || START_ROOM_URL.startsWith('https://')) { + roomId = '/_/global/' + START_ROOM_URL.replace('http://', '').replace('https://', ''); + } else { + roomId = urlManager.editUrlForRoom(START_ROOM_URL, null, null); + } } else { roomId = window.location.pathname + window.location.hash; } diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index e5aa5deb..0ee1906f 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -1,4 +1,5 @@ const DEBUG_MODE: boolean = process.env.DEBUG_MODE == "true"; +const START_ROOM_URL : string = process.env.START_ROOM_URL || 'tcm/workadventure/floor0'; const API_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.API_URL || "pusher.workadventure.localhost"); const UPLOADER_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.UPLOADER_URL || 'uploader.workadventure.localhost'); const ADMIN_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.ADMIN_URL || "workadventure.localhost"); @@ -14,6 +15,7 @@ const MAX_EXTRAPOLATION_TIME = 100; // Extrapolate a maximum of 250ms if no new export { DEBUG_MODE, + START_ROOM_URL, API_URL, UPLOADER_URL, ADMIN_URL, diff --git a/front/webpack.config.js b/front/webpack.config.js index 82bb34fa..3b97081c 100644 --- a/front/webpack.config.js +++ b/front/webpack.config.js @@ -45,7 +45,7 @@ module.exports = { new webpack.ProvidePlugin({ Phaser: 'phaser' }), - new webpack.EnvironmentPlugin(['API_URL', 'UPLOADER_URL', 'ADMIN_URL', 'DEBUG_MODE', 'TURN_SERVER', 'TURN_USER', 'TURN_PASSWORD', 'JITSI_URL', 'JITSI_PRIVATE_MODE']) + new webpack.EnvironmentPlugin(['API_URL', 'UPLOADER_URL', 'ADMIN_URL', 'DEBUG_MODE', 'TURN_SERVER', 'TURN_USER', 'TURN_PASSWORD', 'JITSI_URL', 'JITSI_PRIVATE_MODE', 'START_ROOM_URL']) ], }; From d79a18ee815c8f76226f386a50675164a63dfb49 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Fri, 8 Jan 2021 11:41:18 +0100 Subject: [PATCH 11/19] Removed unused URL_ROOM_STARTED variable from pusher and back --- back/src/Enum/EnvironmentVariable.ts | 2 -- pusher/src/Enum/EnvironmentVariable.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/back/src/Enum/EnvironmentVariable.ts b/back/src/Enum/EnvironmentVariable.ts index 00750969..2cbfbf2e 100644 --- a/back/src/Enum/EnvironmentVariable.ts +++ b/back/src/Enum/EnvironmentVariable.ts @@ -1,5 +1,4 @@ const SECRET_KEY = process.env.SECRET_KEY || "THECODINGMACHINE_SECRET_KEY"; -const URL_ROOM_STARTED = "/Floor0/floor0.json"; const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64; const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48; const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false; @@ -16,7 +15,6 @@ export const SOCKET_IDLE_TIMER = parseInt(process.env.SOCKET_IDLE_TIMER as strin export { SECRET_KEY, - URL_ROOM_STARTED, MINIMUM_DISTANCE, ADMIN_API_URL, ADMIN_API_TOKEN, diff --git a/pusher/src/Enum/EnvironmentVariable.ts b/pusher/src/Enum/EnvironmentVariable.ts index 17f80f9c..5b3ec9c4 100644 --- a/pusher/src/Enum/EnvironmentVariable.ts +++ b/pusher/src/Enum/EnvironmentVariable.ts @@ -1,5 +1,4 @@ const SECRET_KEY = process.env.SECRET_KEY || "THECODINGMACHINE_SECRET_KEY"; -const URL_ROOM_STARTED = "/Floor0/floor0.json"; const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64; const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48; const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false; @@ -16,7 +15,6 @@ export const SOCKET_IDLE_TIMER = parseInt(process.env.SOCKET_IDLE_TIMER as strin export { SECRET_KEY, - URL_ROOM_STARTED, MINIMUM_DISTANCE, API_URL, ADMIN_API_URL, From ae48284460efa8056032631eff8331ba7457ad9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 21 Jan 2021 09:02:47 +0100 Subject: [PATCH 12/19] Fixing docker-compose startup With the addition of ./template.sh in #623, we now need to call the templater on each container startup, even in development environments. --- docker-compose.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 23fa58a4..e5333d29 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -29,7 +29,8 @@ services: API_URL: pusher.workadventure.localhost UPLOADER_URL: uploader.workadventure.localhost ADMIN_URL: workadventure.localhost - STARTUP_COMMAND_1: yarn install + STARTUP_COMMAND_1: ./templater.sh + STARTUP_COMMAND_2: yarn install TURN_SERVER: "turn:coturn.workadventu.re:443,turns:coturn.workadventu.re:443" TURN_USER: workadventure TURN_PASSWORD: WorkAdventure123 From bbf932539693b84c8bd8f5808365783545c1892e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 21 Jan 2021 09:40:11 +0100 Subject: [PATCH 13/19] Simplifying code and making START_ROOM_URL compatible with public (_) and private (@) paths --- .env.template | 2 +- front/src/Connexion/ConnectionManager.ts | 10 +++------- front/src/Enum/EnvironmentVariable.ts | 2 +- front/src/Url/UrlManager.ts | 18 ++---------------- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/.env.template b/.env.template index ce3937d3..330f3865 100644 --- a/.env.template +++ b/.env.template @@ -5,4 +5,4 @@ JITSI_PRIVATE_MODE=false JITSI_ISS= SECRET_JITSI_KEY= ADMIN_API_TOKEN=123 -START_ROOM_URL=/Floor0/floor0.json \ No newline at end of file +START_ROOM_URL=/_/global/maps.workadventure.localhost/Floor0/floor0.json diff --git a/front/src/Connexion/ConnectionManager.ts b/front/src/Connexion/ConnectionManager.ts index b7788536..de8cd234 100644 --- a/front/src/Connexion/ConnectionManager.ts +++ b/front/src/Connexion/ConnectionManager.ts @@ -27,9 +27,9 @@ class ConnectionManager { const organizationSlug = data.organizationSlug; const worldSlug = data.worldSlug; const roomSlug = data.roomSlug; - urlManager.editUrlForRoom(roomSlug, organizationSlug, worldSlug); - const room = new Room(window.location.pathname + window.location.hash); + const room = new Room('/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug + window.location.hash); + urlManager.pushRoomIdToUrl(room); return Promise.resolve(room); } else if (connexionType === GameConnexionTypes.organization || connexionType === GameConnexionTypes.anonymous || connexionType === GameConnexionTypes.empty) { const localUser = localUserStore.getLocalUser(); @@ -48,11 +48,7 @@ class ConnectionManager { } let roomId: string if (connexionType === GameConnexionTypes.empty) { - if (START_ROOM_URL.startsWith('http://') || START_ROOM_URL.startsWith('https://')) { - roomId = '/_/global/' + START_ROOM_URL.replace('http://', '').replace('https://', ''); - } else { - roomId = urlManager.editUrlForRoom(START_ROOM_URL, null, null); - } + roomId = START_ROOM_URL; } else { roomId = window.location.pathname + window.location.hash; } diff --git a/front/src/Enum/EnvironmentVariable.ts b/front/src/Enum/EnvironmentVariable.ts index 0ee1906f..a71506eb 100644 --- a/front/src/Enum/EnvironmentVariable.ts +++ b/front/src/Enum/EnvironmentVariable.ts @@ -1,5 +1,5 @@ const DEBUG_MODE: boolean = process.env.DEBUG_MODE == "true"; -const START_ROOM_URL : string = process.env.START_ROOM_URL || 'tcm/workadventure/floor0'; +const START_ROOM_URL : string = process.env.START_ROOM_URL || '/_/global/maps.workadventure.localhost/Floor0/floor0.json'; const API_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.API_URL || "pusher.workadventure.localhost"); const UPLOADER_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.UPLOADER_URL || 'uploader.workadventure.localhost'); const ADMIN_URL = (process.env.API_PROTOCOL || (typeof(window) !== 'undefined' ? window.location.protocol : 'http:')) + '//' + (process.env.ADMIN_URL || "workadventure.localhost"); diff --git a/front/src/Url/UrlManager.ts b/front/src/Url/UrlManager.ts index 443dcee5..31862899 100644 --- a/front/src/Url/UrlManager.ts +++ b/front/src/Url/UrlManager.ts @@ -32,26 +32,12 @@ class UrlManager { return match ? match [1] : null; } - - //todo: simply use the roomId - //todo: test this with cypress - public editUrlForRoom(roomSlug: string, organizationSlug: string|null, worldSlug: string |null): string { - let newUrl:string; - if (organizationSlug) { - newUrl = '/@/'+organizationSlug+'/'+worldSlug+'/'+roomSlug; - } else { - newUrl = '/@/'+roomSlug; - } - history.pushState({}, 'WorkAdventure', newUrl); - return newUrl; - } - public pushRoomIdToUrl(room:Room): void { - if (window.location.pathname === room.id) return; + if (window.location.pathname === room.id) return; const hash = window.location.hash; history.pushState({}, 'WorkAdventure', room.id+hash); } - + public getStartLayerNameFromUrl(): string|null { const hash = window.location.hash; return hash.length > 1 ? hash.substring(1) : null; From 3d84a9c8cd6221b9f97a94a115a088b7a80ccd17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 21 Jan 2021 10:16:08 +0100 Subject: [PATCH 14/19] Turning French 'Moi' into English 'Me' --- front/src/WebRtc/DiscussionManager.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/front/src/WebRtc/DiscussionManager.ts b/front/src/WebRtc/DiscussionManager.ts index 4282603b..a2da32b2 100644 --- a/front/src/WebRtc/DiscussionManager.ts +++ b/front/src/WebRtc/DiscussionManager.ts @@ -170,7 +170,7 @@ export class DiscussionManager { const pMessage: HTMLParagraphElement = document.createElement('p'); const date = new Date(); if(isMe){ - name = 'Moi'; + name = 'Me'; } pMessage.innerHTML = `${name} @@ -221,7 +221,7 @@ export class DiscussionManager { this.activeDiscussion = false; this.divDiscuss?.classList.remove('active'); } - + public setUserInputManager(userInputManager : UserInputManager){ this.userInputManager = userInputManager; } @@ -231,4 +231,4 @@ export class DiscussionManager { } } -export const discussionManager = new DiscussionManager(); \ No newline at end of file +export const discussionManager = new DiscussionManager(); From 4ad7f4d5a37cd4c6043f017c579e140db0beb3e3 Mon Sep 17 00:00:00 2001 From: kharhamel Date: Fri, 22 Jan 2021 15:01:10 +0100 Subject: [PATCH 15/19] changed the color of the chat links and unit test --- front/src/WebRtc/DiscussionManager.ts | 11 +---------- front/src/WebRtc/HtmlUtils.ts | 7 +++++++ front/tests/Phaser/Game/HtmlUtilsTest.ts | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 front/tests/Phaser/Game/HtmlUtilsTest.ts diff --git a/front/src/WebRtc/DiscussionManager.ts b/front/src/WebRtc/DiscussionManager.ts index a2da32b2..7653bc7a 100644 --- a/front/src/WebRtc/DiscussionManager.ts +++ b/front/src/WebRtc/DiscussionManager.ts @@ -151,15 +151,6 @@ export class DiscussionManager { this.nbpParticipants.innerText = `PARTICIPANTS (${nb})`; } - private urlify(text: string) { - const urlRegex = /(https?:\/\/[^\s]+)/g; - return text.replace(urlRegex, (url: string) => { - return '' + url + ''; - }) - // or alternatively - // return text.replace(urlRegex, '$1') - } - public addMessage(name: string, message: string, isMe: boolean = false) { const divMessage: HTMLDivElement = document.createElement('div'); divMessage.classList.add('message'); @@ -179,7 +170,7 @@ export class DiscussionManager { divMessage.appendChild(pMessage); const userMessage: HTMLParagraphElement = document.createElement('p'); - userMessage.innerHTML = this.urlify(message); + userMessage.innerHTML = HtmlUtils.urlify(message); userMessage.classList.add('body'); divMessage.appendChild(userMessage); this.divMessages?.appendChild(divMessage); diff --git a/front/src/WebRtc/HtmlUtils.ts b/front/src/WebRtc/HtmlUtils.ts index b7cb2124..81f069b3 100644 --- a/front/src/WebRtc/HtmlUtils.ts +++ b/front/src/WebRtc/HtmlUtils.ts @@ -17,4 +17,11 @@ export class HtmlUtils { elem.remove(); return elem as T; } + + public static urlify(text: string): string { + const urlRegex = /(https?:\/\/[^\s]+)/g; + return text.replace(urlRegex, (url: string) => { + return '' + url + ''; + }) + } } diff --git a/front/tests/Phaser/Game/HtmlUtilsTest.ts b/front/tests/Phaser/Game/HtmlUtilsTest.ts new file mode 100644 index 00000000..8ef1d476 --- /dev/null +++ b/front/tests/Phaser/Game/HtmlUtilsTest.ts @@ -0,0 +1,14 @@ +import "jasmine"; +import {HtmlUtils} from "../../../src/WebRtc/HtmlUtils"; + +describe("urlify()", () => { + it("should transform an url into a link", () => { + const text = HtmlUtils.urlify('https://google.com'); + expect(text).toEqual('https://google.com'); + }); + + it("should not transform a normal text into a link", () => { + const text = HtmlUtils.urlify('hello'); + expect(text).toEqual('hello'); + }); +}); \ No newline at end of file From 39b433eef5ca8933ed3f0f976e26c3d0d03d5cf3 Mon Sep 17 00:00:00 2001 From: TabascoEye Date: Sat, 23 Jan 2021 01:16:13 +0100 Subject: [PATCH 16/19] Update GameScene.ts stop all the map specific stuff (Jitsi, coWebsite, Audio) when leaving the scene Fixes #633 --- front/src/Phaser/Game/GameScene.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index c2cb0950..55f89321 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -698,6 +698,10 @@ export class GameScene extends ResizableScene implements CenterListener { } public cleanupClosingScene(): void { + // stop playing audio, close any open website, stop any open Jitsi + coWebsiteManager.closeCoWebsite(); + this.stopJitsi(); + this.playAudio(undefined); // We are completely destroying the current scene to avoid using a half-backed instance when coming back to the same map. if(this.connection) { this.connection.closeConnection(); From 8609cda0d0109a34e245766129a60d08158aaea2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 25 Jan 2021 11:18:48 +0100 Subject: [PATCH 17/19] Add a parameter to allow changing phaser renderer Recently, some Macs have been crashing running WorkAdventure. Hard to say if this is related to Phaser 3.50 upgrade or to the new MacOS version. It happens mostly on Mac Air and might be related to WebGL rendering. This commit allows to switch to CANVAS renderer by adding `?phaserMode=canvas` in the URL --- front/src/index.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/front/src/index.ts b/front/src/index.ts index acf66cf8..e2b636d1 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -53,8 +53,28 @@ const fps : Phaser.Types.Core.FPSConfig = { smoothStep: false } +// the ?phaserMode=canvas parameter can be used to force Canvas usage +let params = new URLSearchParams(document.location.search.substring(1)); +let phaserMode = params.get("phaserMode"); +let mode: number; +switch (phaserMode) { + case 'auto': + case null: + mode = Phaser.AUTO; + break; + case 'canvas': + mode = Phaser.CANVAS; + break; + case 'webgl': + mode = Phaser.WEBGL; + break; + default: + throw new Error('phaserMode parameter must be one of "auto", "canvas" or "webgl"'); +} + + const config: GameConfig = { - type: Phaser.AUTO, + type: mode, title: "WorkAdventure", width: width / RESOLUTION, height: height / RESOLUTION, From c2c8680dae43b5c0c05366b5e2317d720fcc5e6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 25 Jan 2021 12:02:00 +0100 Subject: [PATCH 18/19] Fix linting --- front/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/index.ts b/front/src/index.ts index e2b636d1..b9a00731 100644 --- a/front/src/index.ts +++ b/front/src/index.ts @@ -54,8 +54,8 @@ const fps : Phaser.Types.Core.FPSConfig = { } // the ?phaserMode=canvas parameter can be used to force Canvas usage -let params = new URLSearchParams(document.location.search.substring(1)); -let phaserMode = params.get("phaserMode"); +const params = new URLSearchParams(document.location.search.substring(1)); +const phaserMode = params.get("phaserMode"); let mode: number; switch (phaserMode) { case 'auto': From ab0fe63cb2a546ce561f4b23b71e82718f79a995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 25 Jan 2021 22:42:44 +0100 Subject: [PATCH 19/19] Adding start room url to develop env --- deeployer.libsonnet | 1 + 1 file changed, 1 insertion(+) diff --git a/deeployer.libsonnet b/deeployer.libsonnet index 89571945..1ad58891 100644 --- a/deeployer.libsonnet +++ b/deeployer.libsonnet @@ -79,6 +79,7 @@ "TURN_USER": "workadventure", "TURN_PASSWORD": "WorkAdventure123", "JITSI_PRIVATE_MODE": if env.SECRET_JITSI_KEY != '' then "true" else "false", + "START_ROOM_URL": "/_/global/maps."+url+"/Floor0/floor0.json" //"GA_TRACKING_ID": "UA-10196481-11" } },