Commit 17966431 authored by Mitchell Moore's avatar Mitchell Moore Committed by Krish Moodbidri
Browse files

Fix variable mixup. Log Room ID to client console

parent 13f7b75e
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<script src="static/scripts/function.js"></script> <script src="static/scripts/function.js"></script>
<script> <script>
console.info('Room ID: {{ room_id }}');
var socket = io.connect('http://' + document.domain + ':' + location.port); var socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on( 'connect', function() { socket.on( 'connect', function() {
......
...@@ -16,8 +16,8 @@ app = create_app(config_name) ...@@ -16,8 +16,8 @@ app = create_app(config_name)
app.config['SECRET_KEY'] = 'vnkdjnfjknfl1232#' app.config['SECRET_KEY'] = 'vnkdjnfjknfl1232#'
socketio = SocketIO(app) socketio = SocketIO(app)
global username_global # global username_global
global room_global # global room_global
def create_account(username, fullname, reason): def create_account(username, fullname, reason):
...@@ -31,37 +31,39 @@ def create_account(username, fullname, reason): ...@@ -31,37 +31,39 @@ def create_account(username, fullname, reason):
def account_agent(*args): def account_agent(*args):
# Todo: Code to create a consumer based on the username goes here # Todo: Code to create a consumer based on the username goes here
# Todo: Goal is to have it listening for confirmation. # Todo: Goal is to have it listening for confirmation.
global username_global username = session['username']
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tAccount successfully created for ' + username_global) room = str(session['uid'])
socketio.emit("account ready", room=room_global)
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tAccount successfully created for ' + username)
socketio.emit("account ready", room=room)
return True return True
@socketio.on('user connected') @socketio.on('user connected')
def user_connected(json, methods=['GET', 'POST']): def user_connected(json, methods=['GET', 'POST']):
global username_global
global room_global
username_global = json["user"] username = json["user"]
room_global = str(session['uid']) room = str(session['uid'])
join_room(room_global) join_room(room)
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username_global + ' connected.') print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' connected.')
print('\t\t\t|-----Room ID: ' + room_global) print('\t\t\t|-----Room ID: ' + room)
@socketio.on('request account') @socketio.on('request account')
def request_account(json, methods=['GET', 'POST']): def request_account(json, methods=['GET', 'POST']):
print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tQueue request received: ' + str(json)) print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tQueue request received: ' + str(json))
room = str(session['uid'])
try: try:
# create_account(json['username'], json['fullname'], json['reason']) # create_account(json['username'], json['fullname'], json['reason'])
tasks.celery_create_account(json['username'], json['fullname'], json['reason'], room_global, socketio) tasks.celery_create_account(json['username'], json['fullname'], json['reason'], room, socketio)
except Exception as e: except Exception as e:
print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in account creation: ", e) print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in account creation: ", e)
socketio.emit("Account creation failed", room=room_global) socketio.emit("Account creation failed", room)
if __name__ == '__main__': if __name__ == '__main__':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment