Commit 9d8eeec9 authored by Taddeus Kroes's avatar Taddeus Kroes

Made TUIO server more robust against stopping of the program.

parent 1aff9a2e
......@@ -15,7 +15,7 @@ class TuioServer2D(Logger):
# OSC server that listens to incoming TUIO events
self.server = OSCServer(self.__class__._tuio_address)
#self.server.addDefaultHandlers()
self.server.addDefaultHandlers()
self.server.addMsgHandler('/tuio/2Dobj', self._receive)
self.server.addMsgHandler('/tuio/2Dcur', self._receive)
self.server.addMsgHandler('/tuio/2Dblb', self._receive)
......@@ -67,8 +67,11 @@ class TuioServer2D(Logger):
self.handler_obj.point_down(sid, x, y)
def start(self):
self.log('Starting OSC server')
self.server.serve_forever()
try:
self.log('Starting OSC server')
self.server.serve_forever()
except SystemExit:
self.stop()
def stop(self):
self.log('Stopping OSC server')
......@@ -90,4 +93,8 @@ if __name__ == '__main__':
v = 1 if len(sys.argv) < 2 else int(sys.argv[1])
server = TuioServer2D(Handler(verbose=v), verbose=v)
server.start()
try:
server.start()
except KeyboardInterrupt:
server.stop()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment