Updating zukebox_control_point.py
authorHenry Bilby <henrymiller.engenheiro@gmail.com>
Thu, 14 May 2009 22:39:13 +0000 (18:39 -0400)
committerHenry Bilby <henrymiller.engenheiro@gmail.com>
Thu, 14 May 2009 22:39:13 +0000 (18:39 -0400)
control_point/.zukebox_control_point.py.swp [deleted file]
control_point/zukebox_control_point.py

diff --git a/control_point/.zukebox_control_point.py.swp b/control_point/.zukebox_control_point.py.swp
deleted file mode 100644 (file)
index d31e7ea..0000000
Binary files a/control_point/.zukebox_control_point.py.swp and /dev/null differ
index 408be8d..9cac491 100644 (file)
@@ -7,3 +7,37 @@ from brisa.core.network import parse_url
 from brisa.core.threaded_call import run_async_function
 
 from brisa.upnp.control_point.control_point import ControlPoint
+
+service = ('u','urn:schemas-upnp-org:service:Playlist:1')
+zukebox_type = 'urn:schemas-upnp-org:device:MediaServer:1'
+
+def on_new_device(dev):
+
+    print 'Got new device: ', dev.udn
+    if not dev:
+        return
+
+def on_removed_device(udn):
+
+    print 'Device is gone: ', udn
+
+def get_switch_service(device):
+    return device.services[service[1]]
+
+def create_control_point():
+    """ Creates the control point and binds callbacks to device events.
+    """
+    c = ControlPoint()
+    c.subscribe('new_device_event', on_new_device)
+    c.subscribe('removed_device_event', on_removed_device)
+    return c
+
+
+def main():
+    """ Main loop iteration receiving input commands.
+    """
+    c = create_control_point()
+    c.start()
+    #run_async_function(_handle_cmds, (c, ))
+    reactor.add_after_stop_func(c.stop)
+    reactor.main()