(self, data)
Handles an incoming Ramp message.
Handles an incoming Ramp message.
Handles an incoming Ramp message .
def _receive_protocol(self, data):
        """ Handles an incoming Ramp message. """
        message_type = data[RAMP_ATTR_TYPE]

        if message_type == RAMP_TYPE_STATUS:
            self._update_status(data[RAMP_ATTR_STATUS])

        elif message_type == RAMP_TYPE_RESPONSE:
            # Match it with the command that we send
            try:
                cmd_type, cmd_event = \
                    self.commands.pop(data[RAMP_ATTR_CMD_ID])

            except KeyError:
                # If CMD_ID did not exist or we do not recognize command
                return

            # Handle response, currently no response handlers
            if cmd_type in (RAMP_TYPE_PLAY, RAMP_TYPE_VOLUME,
                            RAMP_TYPE_INFO):

                self._update_status(data[RAMP_ATTR_STATUS])

            else:
                self.logger.warning(
                    "Unhandled response for command {}: {}".format(
                        cmd_type, data))

            # Alert code that is waiting for this command to get response
            if cmd_event:
                cmd_event.set()

        else:
            BaseSubprotocol._receive_protocol(self, data)
def _receive_protocol ( self , data ) : message_type = data [ RAMP_ATTR_TYPE ] if message_type == RAMP_TYPE_STATUS : self . _update_status ( data [ RAMP_ATTR_STATUS ] ) elif message_type == RAMP_TYPE_RESPONSE : # Match it with the command that we send try : cmd_type , cmd_event = self . commands . pop ( data [ RAMP_ATTR_CMD_ID ] ) except KeyError : # If CMD_ID did not exist or we do not recognize command return # Handle response, currently no response handlers if cmd_type in ( RAMP_TYPE_PLAY , RAMP_TYPE_VOLUME , RAMP_TYPE_INFO ) : self . _update_status ( data [ RAMP_ATTR_STATUS ] ) else : self . logger . warning ( "Unhandled response for command {}: {}" . format ( cmd_type , data ) ) # Alert code that is waiting for this command to get response if cmd_event : cmd_event . set ( ) else : BaseSubprotocol . _receive_protocol ( self , data )