本文整理汇总了Python中OSC.OSCServer方法的典型用法代码示例。如果您正苦于以下问题:Python OSC.OSCServer方法的具体用法?Python OSC.OSCServer怎么用?Python OSC.OSCServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSC
的用法示例。
在下文中一共展示了OSC.OSCServer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import OSCServer [as 别名]
def __init__(self, FAKE_CONNECTION=None):
super(Anoto, self).__init__()
if FAKE_CONNECTION is None:
FAKE_CONNECTION = config.getboolean('Anoto Server',
'fake_connection')
self.speed = TraceSpeed()
self.keep_serving = True
if not FAKE_CONNECTION:
receive_address = (config.get('Anoto Server', 'receive_ip'),
config.getint('Anoto Server', 'receive_port'))
# self.osc_server = OSC.OSCServer(receive_address) # basic
self.osc_server = OSC.ThreadingOSCServer(receive_address)
else:
receive_address = (config.get('Anoto Server', 'fake_receive_ip'),
config.getint('Anoto Server', 'receive_port'))
self.osc_server = OSC.ThreadingOSCServer(receive_address)
# either way - print tracebacks
self.osc_server.print_tracebacks = True
示例2: start_osc_server
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import OSCServer [as 别名]
def start_osc_server(self):
def serve_long(osc_server):
'''Target function for OSC Server Thead
'''
try:
while self.keep_serving:
osc_server.handle_request()
except Exception as e:
if not e.args[0] == 9:
raise e
# Start OSCServer
if DEBUG:
print("Starting OSCServer.")
# self.thread_target = self.osc_server.serve_forever
self.server_thread = threading.Thread(
target=serve_long,
args=(self.osc_server, ))
self.server_thread.start()
self.server_thread.setName('OSC Client')
示例3: close_connection
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import OSCServer [as 别名]
def close_connection(self):
if DEBUG:
print("Closing OSCServer.")
self.keep_serving = False
self.osc_server.client.close()
self.osc_server.server_close()
if DEBUG:
print("Waiting for Server-thread to finish")
self.server_thread.join()
示例4: __init__
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import OSCServer [as 别名]
def __init__(self,
osc_server,
opc_client,
scenes=None,
first_scene=None,
no_interaction_timeout=5 * 60,
max_scene_timeout=15 * 60,
tags=[]):
# type: (OSCServer, Client, List(OSCClient), {str, Scene}) -> None
self.osc_server = osc_server
self.opc_client = opc_client
self.fps = STATE.fps
self.no_interaction_timeout = no_interaction_timeout
self.max_scene_timeout = max_scene_timeout
# Load all scenes from effects package. Then set initial index and load it up
if not tags:
print "Tags not specified. Using only scenes with tags [production]"
tags = [Scene.TAG_PRODUCTION]
loaded_scenes = load_scenes_and_fountains(tags=tags)
self.scenes = scenes or loaded_scenes
self.non_game_scenes = [name for name, scene in self.scenes.items()
if not scene.is_game()] # TODO: validation
map(lambda s: s.after_all_scenes_loaded(), self.scenes.values())
self.curr_scene = None
self.queued_scene = self.scenes[first_scene if first_scene else self.non_game_scenes[0]]
self._last_scene_change_timestamp = time.time()
self.serve = False
self.is_running = False
self.osc_data = OSCDataAccumulator(last_data=None)
self.setup_osc_input_handlers({0: 50})
示例5: mode_started
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import OSCServer [as 别名]
def mode_started(self):
"""Starts the OSC server when this OSC game mode is loaded"""
receive_address = (self.serverIP, self.serverPort)
self.server = OSC.OSCServer(receive_address)
self.server.addDefaultHandlers()
self.server.addMsgHandler("default", self.process_message)
# start the OSC server
self.game.logger.info("OSC Server listening on %s:%s", self.serverIP,
self.serverPort)
self.server_thread = threading.Thread(target=self.server.serve_forever)
self.server_thread.daemon = True # needed so OSC thread shuts down
self.server_thread.start()
self.set_initial_closed_switches()