mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	Add client side event handlers for update-* events.
This commit is contained in:
		@@ -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))
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
      });
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user