Example #1
0
 def process_mopidy_message(self, message):
     """Process messages from the rest of Mopidy."""
     if message['command'] == 'play_uri':
         response = self.play_uri(message['uri'])
         connection = unpickle_connection(message['reply_to'])
         connection.send(response)
     elif message['command'] == 'deliver_data':
         self.deliver_data(message['caps'], message['data'])
     elif message['command'] == 'end_of_data_stream':
         self.end_of_data_stream()
     elif message['command'] == 'set_state':
         response = self.set_state(message['state'])
         connection = unpickle_connection(message['reply_to'])
         connection.send(response)
     elif message['command'] == 'get_volume':
         volume = self.get_volume()
         connection = unpickle_connection(message['reply_to'])
         connection.send(volume)
     elif message['command'] == 'set_volume':
         response = self.set_volume(message['volume'])
         connection = unpickle_connection(message['reply_to'])
         connection.send(response)
     elif message['command'] == 'set_position':
         response = self.set_position(message['position'])
         connection = unpickle_connection(message['reply_to'])
         connection.send(response)
     elif message['command'] == 'get_position':
         response = self.get_position()
         connection = unpickle_connection(message['reply_to'])
         connection.send(response)
     else:
         logger.warning(u'Cannot handle message: %s', message)
Example #2
0
    def process_message(self, message):
        """
        Processes messages with the MPD frontend as destination.

        :param message: the message
        :type message: dict
        """
        assert message['to'] == 'frontend', \
            u'Message recipient must be "frontend".'
        if message['command'] == 'mpd_request':
            response = self.dispatcher.handle_request(message['request'])
            connection = unpickle_connection(message['reply_to'])
            connection.send(response)
        else:
            pass # Ignore messages for other frontends