# Drop the connection to the builder
self.current_user.disconnected()
- #def on_message(self, message):
- # # Decode message
- # message = self._decode_json_message(message)
- #
- # with self.db.transaction():
- # self.current_user.log_stats(**message)
+ def on_message(self, message):
+ # Decode message
+ message = self._decode_json_message(message)
+
+ # Fetch the message type
+ type = message.get("type")
+
+ # Handle stats
+ if type == "stats":
+ self._handle_stats(message)
+
+ # Log an error and ignore any other messages
+ else:
+ log.error("Received message of type '%s' which we cannot handle here" % type)
+
+ def _handle_stats(self, message):
+ """
+ Handles stats messages
+ """
+ with self.db.transaction():
+ self.builder.log_stats(**message)
class BuilderListHandler(base.BaseHandler):