From 099cb06741991279fe952371faaee9dc430cd1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sat, 8 Mar 2014 15:08:25 +0100 Subject: [PATCH] better osc message cmds --- osc2cam/osc2cam/main.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/osc2cam/osc2cam/main.py b/osc2cam/osc2cam/main.py index 6ae3454..3af2e90 100644 --- a/osc2cam/osc2cam/main.py +++ b/osc2cam/osc2cam/main.py @@ -113,21 +113,18 @@ class OSC2CamServer(SimpleOSCServer): def dispatchMessage(self, osc_address, typetags, args, packet, client_address): """ dispatches parsed osc messages to the ip cam command methods""" - rule = re.compile("^/(.*?)/(\d+)/(.*?)$") - res = rule.match(osc_address) - if res: - _, cam_id, command = res.groups() - cam_id = int(cam_id) - if command == "moveCam": - self.move_cam(cam_id, args) - elif command == "setCamPreset": - self.set_cam_preset(cam_id, args) - elif command == "useCamPreset": - self.use_cam_preset(cam_id, args) - elif command == "zoomCam": - self.zoom_cam(cam_id, args) - elif command == "toggleNightView": - self.toggle_night_view(cam_id, args) + + cam_id = args.pop(0) + if osc_address == "/moveCam": + self.move_cam(cam_id, args) + elif osc_address == "/setCamPreset": + self.set_cam_preset(cam_id, args) + elif osc_address == "/useCamPreset": + self.use_cam_preset(cam_id, args) + elif osc_address == "/zoomCam": + self.zoom_cam(cam_id, args) + elif osc_address == "/toggleNightView": + self.toggle_night_view(cam_id, args) def main():