[Add] init時にOSCの起動確認を行う処理を追加

裏でOSC receive処理は回りっぱなし
This commit is contained in:
misygauziya
2023-07-24 23:50:35 +09:00
parent 8e31472978
commit 36374d6979
2 changed files with 43 additions and 5 deletions

View File

@@ -1,5 +1,9 @@
from time import sleep
from typing import List
from pythonosc import osc_message_builder
from pythonosc import udp_client
from pythonosc import dispatcher
from pythonosc import osc_server
# send OSC message typing
def send_typing(flag=False, ip_address="127.0.0.1", port=9000):
@@ -18,4 +22,16 @@ def send_message(message=None, ip_address="127.0.0.1", port=9000):
msg.add_arg(True)
b_msg = msg.build()
client = udp_client.SimpleUDPClient(ip_address, port)
client.send(b_msg)
client.send(b_msg)
def send_test_action(ip_address="127.0.0.1", port=9000):
client = udp_client.SimpleUDPClient(ip_address, port)
client.send_message("/input/Vertical", 1)
sleep(0.01)
client.send_message("/input/Vertical", False)
def receive_osc_parameters(target, filter="/*", ip_address="127.0.0.1", port=9001):
_dispatcher = dispatcher.Dispatcher()
_dispatcher.map(filter, target)
server = osc_server.ThreadingOSCUDPServer((ip_address, port), _dispatcher)
server.serve_forever()