diff --git a/app/main/events.py b/app/main/events.py index af777595..8f03ec7c 100644 --- a/app/main/events.py +++ b/app/main/events.py @@ -49,14 +49,14 @@ def background_task(user_id, session_id): jobs = list(map(lambda x: x.to_dict(), user.jobs)) ''' Send initial values. ''' socketio.emit('init-corpora', - {'data': json.dumps(corpora)}, + json.dumps(corpora), room=session_id) socketio.emit('init-jobs', - {'data': json.dumps(jobs)}, + json.dumps(jobs), room=session_id) ''' TODO: Implement maximum runtime for this loop. ''' while session_id not in disconnected: - print(session_id + ' running') + # print(session_id + ' running') # socketio.emit('message', 'heartbeat', room=session_id) ''' Get current values from the database ''' new_corpora = list(map(lambda x: x.to_dict(), user.corpora)) diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2 index a6db59f4..838842b8 100644 --- a/app/templates/base.html.j2 +++ b/app/templates/base.html.j2 @@ -26,17 +26,27 @@ var socket = io(); socket.on('init-corpora', function(msg) { - corpora = JSON.parse(msg.data); + corpora = JSON.parse(msg); for (subscriber of corporaSubscribers) {subscriber.init();} }); socket.on('init-jobs', function(msg) { - jobs = JSON.parse(msg.data); + jobs = JSON.parse(msg); for (subscriber of jobsSubscribers) {subscriber.init();} }); + socket.on('update-corpora', function(msg) { + console.log(msg); + }); + + + socket.on('update-jobs', function(msg) { + console.log(msg); + }); + + socket.on('message', function(msg) { console.log(msg); });