diff --git a/CHANGELOG.md b/CHANGELOG.md index 843c7c4..f56427d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Releases +## [0.5.2] - 27/11/23 +- UMA-35: [Bug] Set websocket URL based on environment + ## [0.5.1] - 27/11/23 - UMA-34: [Bug] Broken deployment due to missing gevent installation @@ -87,4 +90,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [0.4.0]: https://github.com/jrsmth/ultima/compare/0.3.2...0.4.0 [0.4.1]: https://github.com/jrsmth/ultima/compare/0.4.0...0.4.1 [0.5.0]: https://github.com/jrsmth/ultima/compare/0.4.1...0.5.0 -[0.5.1]: https://github.com/jrsmth/ultima/compare/0.5.0...0.5.1 \ No newline at end of file +[0.5.1]: https://github.com/jrsmth/ultima/compare/0.5.0...0.5.1 +[0.5.2]: https://github.com/jrsmth/ultima/compare/0.5.1...0.5.2 \ No newline at end of file diff --git a/src/app/config/config.py b/src/app/config/config.py index 06abf49..35dc97c 100644 --- a/src/app/config/config.py +++ b/src/app/config/config.py @@ -1,10 +1,13 @@ class Config(object): + APP_URL = "http://localhost:8080" REDIS_URL = "redis://@localhost:6379/0" class DevConfig(Config): + APP_URL = "http://localhost:8080" REDIS_URL = "rediss://red-cklv99jj89us738u33i0:c1vXNdmZhDpXxxOTrkEsaBM9m9Kgk67z@frankfurt-redis.render.com:6379" class ProductionConfig(Config): + APP_URL = "https://www.ultima.jrsmth.io/" REDIS_URL = 'redis://red-cklv99jj89us738u33i0:6379' diff --git a/src/app/game/game.py b/src/app/game/game.py index a66cb5e..2cb7360 100644 --- a/src/app/game/game.py +++ b/src/app/game/game.py @@ -1,7 +1,7 @@ import json import random -from flask import render_template, url_for, redirect, Blueprint, Response +from flask import render_template, Blueprint, Response, current_app from src.app.model.board.board import map_to_symbol from src.app.model.board.threeboard import ThreeBoard @@ -21,10 +21,11 @@ def construct_blueprint(messages, socket, redis): @game_page.route("/game//") def game(game_id, user_id): + app_url = current_app.config["APP_URL"] update_game_state(game_id, user_id + ' has joined the game') check_status(game_id) - return render_template("game.html", gameId=game_id, userId=user_id, version=__version__) + return render_template("game.html", appUrl=app_url, gameId=game_id, userId=user_id, version=__version__) @socket.on('restart') def restart(message): diff --git a/src/app/util/redis.py b/src/app/util/redis.py index 1598049..1afb548 100644 --- a/src/app/util/redis.py +++ b/src/app/util/redis.py @@ -33,7 +33,7 @@ def get_complex(self, key): # Standardises a JSON string for conversion into a python dict -def standardise(value): # FixMe :: bit dodgy +def standardise(value): # FixMe :: bit dodgy # Convert Python `False` to JSON-standard `true` standardised = str(value).replace("False,", "false,").replace("True,", "true,") diff --git a/src/resources/static/scripts/game.js b/src/resources/static/scripts/game.js index 8db3535..dc6c4d0 100644 --- a/src/resources/static/scripts/game.js +++ b/src/resources/static/scripts/game.js @@ -1,6 +1,7 @@ let userId; let gameState; let socket; +let appUrl; async function init(gameId) { // Retrieve game state @@ -224,11 +225,9 @@ function restart() { } function connectSocket(gameId) { - // const socket = io(); - socket = io.connect('http://localhost:8080'); // ?? + socket = io.connect(appUrl); - // const socket = io(); - console.log(socket); + console.log(socket); // FixMe socket.on('connect', function() { console.log('connected'); diff --git a/src/resources/templates/game.html b/src/resources/templates/game.html index dd18f14..dd77bc8 100644 --- a/src/resources/templates/game.html +++ b/src/resources/templates/game.html @@ -64,7 +64,9 @@