Look at the type of the message, instantiate the correct class and
        let it parse the message.
508302
def from_bytes(cls, bitstream):
        '''
        
        '''
        from pylisp.packet.lisp.control import type_registry

        # Convert to ConstBitStream (if not already provided)
        if not isinstance(bitstream, ConstBitStream):
            if isinstance(bitstream, Bits):
                bitstream = ConstBitStream(auto=bitstream)
            else:
                bitstream = ConstBitStream(bytes=bitstream)

        # Peek at the bitstream to see which type it is
        type_nr = bitstream.peek('uint:4')

        # Look for the right class
        type_class = type_registry.get_type_class(type_nr)
        if not type_class:
            raise ValueError("Can't handle message type {0}".format(type_nr))

        # Let the specific class handle it from now on
        return type_class.from_bytes(bitstream)
720877
def _parse_message(self, message):
        
        _logger.debug("Parsing received message %r.", self.delivery_no)
        self._message = message
        body_type = message.body_type
        if body_type == c_uamqp.MessageBodyType.NoneType:
            self._body = None
        elif body_type == c_uamqp.MessageBodyType.DataType:
            self._body = DataBody(self._message)
        elif body_type == c_uamqp.MessageBodyType.SequenceType:
            raise TypeError("Message body type Sequence not supported.")
        else:
            self._body = ValueBody(self._message)
        _props = self._message.properties
        if _props:
            _logger.debug("Parsing received message properties %r.", self.delivery_no)
            self.properties = MessageProperties(properties=_props, encoding=self._encoding)
        _header = self._message.header
        if _header:
            _logger.debug("Parsing received message header %r.", self.delivery_no)
            self.header = MessageHeader(header=_header)
        _footer = self._message.footer
        if _footer:
            _logger.debug("Parsing received message footer %r.", self.delivery_no)
            self.footer = _footer.map
        _app_props = self._message.application_properties
        if _app_props:
            _logger.debug("Parsing received message application properties %r.", self.delivery_no)
            self.application_properties = _app_props.map
        _ann = self._message.message_annotations
        if _ann:
            _logger.debug("Parsing received message annotations %r.", self.delivery_no)
            self.annotations = _ann.map
        _delivery_ann = self._message.delivery_annotations
        if _delivery_ann:
            _logger.debug("Parsing received message delivery annotations %r.", self.delivery_no)
            self.delivery_annotations = _delivery_ann.map
1190451
async def dump_message(self, msg, msg_type=None):
        
        mtype = msg.__class__ if msg_type is None else msg_type
        fields = mtype.f_specs()
        for field in fields:
            await self.message_field(msg=msg, field=field)
49963
private void doSelect(final Message<JsonObject> message) {
    String type = message.body().getString("type");
    if (type != null) {
      switch (type) {
        case "group":
          doSelectGroup(message);
          break;
        case "node":
          doSelectNode(message);
          break;
        default:
          message.reply(new JsonObject().putString("status", "error").putString("message", "Invalid type specified."));
          break;
      }
    } else {
      message.reply(new JsonObject().putString("status", "error").putString("message", "No type specified."));
    }
  }
653119
def evaluate(actual, expected)
      if actual.kind_of?(expected)
        pass new_message.is_a_kind_of(expected)
      else
        fail expected_message.kind_of(expected).not(actual.class)
      end
    end
1072848
function parseSafeMessage(message, status) {
  if (typeof message === 'object') {
    return {status: message.errorCode, message: message.description};
  } else {
    return {status: status, message: message};
  }
}
206677
async def message(self, msg, msg_type=None, obj=None):
        
        elem_type = msg_type if msg_type is not None else msg.__class__
        obj = collections.OrderedDict() if not x.has_elem(obj) else x.get_elem(obj)

        if hasattr(elem_type, 'kv_serialize'):
            msg = elem_type() if msg is None else msg
            return await msg.kv_serialize(self, obj=obj)

        fields = elem_type.f_specs()
        for field in fields:
            await self.message_field(msg=msg, field=field, obj=obj)

        return obj if self.writing else msg
593873
def _cast_message(self, message=None):
        '''
        '''
        if message is None:
            message = {}
        if isinstance(message, Mapping):
            message = Message.load_message(message)
        return message.load_from(self.message, verify=True)
694592
function parse(msg) {
  let model;
  if (typeof msg === 'object') {
    // data is a MessageEvent not a raw string
    msg = msg.data;
  }

  if (msg.startsWith(PullMessage.TYPE)) {
    // pull
    return new PullMessage();
  }

  if (msg.startsWith(RegisteredMessage.TYPE)) {
    // registered ack
    return new RegisteredMessage();
  }

  if (msg.startsWith(PushMessage.TYPE + '/')) {
    // push/modelStr
    model = msg.substring(PushMessage.TYPE.length + 1);
    return new PushMessage(model);
  }

  if (msg.startsWith(PushKevSMessage.TYPE + '/')) {
    // push/kevsStr
    model = msg.substring(PushKevSMessage.TYPE.length + 1);
    return new PushKevSMessage(model);
  }

  if (msg.startsWith(RegisterMessage.TYPE)) {
    // register/nodeName/modelStr
    const payload = msg.substring(RegisterMessage.TYPE.length + 1);
    let index = 0;
    let ch = payload.charAt(index);
    while (index < payload.length && ch !== '/') {
      index++;
      ch = payload[index];
    }
    const nodeName = payload.substring(0, index);
    return new RegisterMessage(nodeName, payload.substring(index + 1));
  }

  return null;
}
1005645
public Object parseType(String input, Type targetType) {
        return typeParser.parseType(input, targetType);
    }
976611
def report_message_type(self, msg):
        
        desc = get_message_description(self.linter, msg.msg_id)
        self.tc.message('inspectionType', id=msg.msg_id, name=msg.symbol, description=desc, category=msg.category)
223896
def parse(self):
        '''  '''
        # Loop while we get new messages
        while True:
            status, self._buffer, packet = Packet.parse_msg(self._buffer)
            # If message is incomplete -> break the loop
            if status == PARSE_RESULT.INCOMPLETE:
                return status

            # If message is OK, add it to receive queue or send to the callback method
            if status == PARSE_RESULT.OK and packet:
                packet.received = datetime.datetime.now()

                if isinstance(packet, UTETeachInPacket) and self.teach_in:
                    response_packet = packet.create_response_packet(self.base_id)
                    self.logger.info('Sending response to UTE teach-in.')
                    self.send(response_packet)

                if self.__callback is None:
                    self.receive.put(packet)
                else:
                    self.__callback(packet)
                self.logger.debug(packet)
64870
def _to_base_type(self, msg):
    """"""
    ent = _message_to_entity(msg, self._modelclass)
    ent.blob_ = self._protocol_impl.encode_message(msg)
    return ent
580064
public <T> T parse(String input, Class<T> targetType) {
        return typeParser.parse(input, targetType);
    }
284775
def ref_for_message_type(self, message_type):
    
    name = self.__normalized_name(message_type)
    if name not in self.__schemas:
      raise KeyError('Message has not been parsed: %s', name)
    return name
111323
def from_message(cls, message='> '):
        
        assert isinstance(message, text_type)

        def get_message_tokens(cli):
            return [(Token.Prompt, message)]
        return cls(get_message_tokens)
1050521
def _ConvertAnyMessage(self, value, message):
    """"""
    if isinstance(value, dict) and not value:
      return
    try:
      type_url = value['@type']
    except KeyError:
      raise ParseError('@type is missing when parsing any message.')

    sub_message = _CreateMessageFromTypeUrl(type_url)
    message_descriptor = sub_message.DESCRIPTOR
    full_name = message_descriptor.full_name
    if _IsWrapperMessage(message_descriptor):
      self._ConvertWrapperMessage(value['value'], sub_message)
    elif full_name in _WKTJSONMETHODS:
      methodcaller(
          _WKTJSONMETHODS[full_name][1], value['value'], sub_message)(self)
    else:
      del value['@type']
      self._ConvertFieldValuePair(value, sub_message)
    # Sets Any message
    message.value = sub_message.SerializeToString()
    message.type_url = type_url