code: def on_recv(self, callback):
          '''
          Register an on_recv callback
          '''
          if callback is None:
              return self.message_client.on_recv(callback)
  
          @tornado.gen.coroutine
          def wrap_callback(body):
              if not isinstance(body, dict):
                  # TODO: For some reason we need to decode here for things
                  #       to work. Fix this.
                  body = salt.utils.msgpack.loads(body)
                  if six.PY3:
                      body = salt.transport.frame.decode_embedded_strs(body)
              ret = yield self._decode_payload(body)
              callback(ret)
          return self.message_client.on_recv(wrap_callbackf on_recv(self, callback):
          '''
          Register an on_recv callback
          '''
          if callback is None:
              return self.message_client.on_recv(callback)
  
          @tornado.gen.coroutine
          def wrap_callback(body):
              if not isinstance(body, dict):
                  # TODO: For some reason we need to decode here for things
                  #       to work. Fix this.
                  body = salt.utils.msgpack.loads(body)
                  if six.PY3:
                      body = salt.transport.frame.decode_embedded_strs(body)
              ret = yield self._decode_payload(body)
              callback(ret)
          return self.message_client.on_recv(wrap_callback)
docs: Register an on_recv callback