annot-server/websockets.py
changeset 23 16a1925df2df
parent 0 e1d4d7a8255a
child 42 926f0426ce78
equal deleted inserted replaced
22:986ee928a866 23:16a1925df2df
    91             'channel' : utils.ANNOTATION_CHANNEL,
    91             'channel' : utils.ANNOTATION_CHANNEL,
    92             'content' : params_annot
    92             'content' : params_annot
    93         }
    93         }
    94 
    94 
    95         def error_callback(failure):
    95         def error_callback(failure):
    96             raise http.HttpException(500,"Error when processing message : %r" % failure)
    96             res = params.copy()
       
    97             res['status'] = 'KO'
       
    98             res['failure'] = str(failure)
       
    99             self.sendMessage(json.dumps(res))
    97 
   100 
    98         def annot_callback(res):
   101         def annot_callback(res):
    99             if 'ts' in res:
   102             if 'ts' in res:
   100                 res['ts'] = res['ts'].isoformat()+'Z'
   103                 res['ts'] = res['ts'].isoformat()+'Z'
   101             if 'uuid' in res:
   104             if 'uuid' in res:
   102                 res['uuid'] = str(res['uuid'])
   105                 res['uuid'] = str(res['uuid'])
       
   106             res['status'] = 'OK'
   103             self.sendMessage(json.dumps(res))
   107             self.sendMessage(json.dumps(res))
   104 
   108 
   105 
   109 
   106         defer = self.process_annotation(params)
   110         defer = self.process_annotation(params)
   107         defer.addErrback(error_callback)
   111         defer.addErrback(error_callback)