code: def encode(self, message):
          '''Encode a message when publishing.'''
          if not isinstance(message, dict):
              message = {'message': message}
          message['time'] = time.time()
          return json.dumps(messagef encode(self, message):
          '''Encode a message when publishing.'''
          if not isinstance(message, dict):
              message = {'message': message}
          message['time'] = time.time()
          return json.dumps(message)
docs: Encode a message when publishing.