Updating zukebox_control_point.py
[zukebox] / control_point / zukebox_control_point.py
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()