Skip to content

Commit

Permalink
Correct URL path port in sockets (#416)
Browse files Browse the repository at this point in the history
* Correct URL path port in sockets

* add flask-cors to requirements (spelt correctly)
  • Loading branch information
mrniket authored and CelineBoudier committed Dec 20, 2017
1 parent 4a43ca0 commit f3c3b33
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions aimmo-game/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ flask-socketio
pykube
requests
six
flask-cors
2 changes: 2 additions & 0 deletions aimmo-game/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import flask
from flask_socketio import SocketIO, emit
from flask_cors import CORS

from simulation.turn_manager import state_provider
from simulation import map_generator
Expand All @@ -21,6 +22,7 @@
from simulation.pickups import pickups_update

app = flask.Flask(__name__)
CORS(app, supports_credentials=True)
socketio = SocketIO()

worker_manager = None
Expand Down
4 changes: 2 additions & 2 deletions example_project/example_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ def get_url(game):
if os.environ.get('AIMMO_MODE', '') == 'minikube':
output = subprocess.check_output([os.environ['MINIKUBE_PATH'], 'service',
'game-%s' % game, '--url'])
return output.strip(), '/game/%s/socket.io' % game
return output.strip(), '/game/%s' % game
else:
return 'http://localhost:%d' % (6001 + int(game) * 1000), '/socket.io'
return 'http://localhost:%d' % (6001 + int(game) * 1000), ''


AIMMO_GAME_SERVER_LOCATION_FUNCTION = get_url
Expand Down
2 changes: 1 addition & 1 deletion players/templates/players/watch.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

function SendAllConnect() {
console.log("Sending Messages...");
gameInstance.SendMessage("World Controller", "SetGameURL", host);
gameInstance.SendMessage("World Controller", "SetGameURL", `${host}:${port}${path}`);
gameInstance.SendMessage("World Controller", "SetGamePort", parseInt(port));
gameInstance.SendMessage("World Controller", "EstablishConnection");
}
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'six',
'pykube',
'hypothesis',
'flask-cors'
],
tests_require=[
'django-setuptest',
Expand Down

0 comments on commit f3c3b33

Please sign in to comment.