Exemple #1
0
 def set_next_song(self, path):
     s = self._socket()
     net.send(s, ('set_next_song', path))
     return
Exemple #2
0
 def __init__(self, host='localhost', port=50000):
     self._host = host
     self._port = int(port)
     s = open_socket(self._host, self._port)
     net.send(s, ('exit',))
Exemple #3
0
    def run(self):
        send = lambda d : net.send(self._client, d, self.stopped, True)
        try:
            data = net.receive(self._client, fStopped=self.stopped, bClose=False)
            if not data:
                self._client.close()
            if data[0] == 'exit':
                self._client.close()

            elif data[0] == 'get_buffer_size':
                bufsize = self._server.get_buffer_size()
                send(bufsize)

            elif data[0] == 'set_buffer_size':
                buf = data[1]
                self._server.set_buffer_size(buf)
                send(True)

            elif data[0] == 'collection':
                col = self._server.get_collection()
                send(col)

            elif data[0] == 'set_next_song':
                self._server.set_next_song(data[1])
                send(True)

            elif data[0] == 'insert_songs':
                self._server.insert_songs_into_playlist(data[1], data[2])
                send(True)

            elif data[0] == 'delete_songs':
                self._server.delete_songs_from_playlist(data[1])
                send(True)

            elif data[0] == 'get_playlist':
                pl = self._server.get_playlist()
                send(pl)

            elif data[0] == 'set_playlist':
                pl = data[1]
                self._server.set_playlist(pl)
                send(True)

            elif data[0] == 'get_current_song':
                song = self._server.get_current_song()
                send(song)

            elif data[0] == 'get_time_to_end':
                t = self._server.get_time_to_end()
                send(t)

            elif data[0] == 'fill_playlist':
                self._server.fill_playlist()
                send(True)

            else:
                self._client.close()


            self._data = data
            self._client.close()

        except AttributeError, e:
            print e
            if self.stopped():
                print 'Client stopped!'
                self._client.close()