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" } }, diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index a9052119..fdefee66 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -610,8 +610,18 @@ export class GameScene extends ResizableScene implements CenterListener { if (url === undefined) { 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 + const mapDirUrl = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/')); + realAudioPath = mapDirUrl + '/' + url; + } + audioManager.loadAudio(realAudioPath); if (loop) { @@ -708,6 +718,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(); 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/src/index.ts b/front/src/index.ts index acf66cf8..b9a00731 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 +const params = new URLSearchParams(document.location.search.substring(1)); +const 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, 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