kivy/oscpy

Async oscpy, question, help !

bueltan opened this issue · 1 comments

Hi, how could I implement oscpy with cooroutines using asyncio, I don't understand how to implement the below.
OSCAsyncServer exist in somewere ?

Server (async) (TODO!)

from oscpy.server import OSCThreadServer

with OSCAsyncServer(port=8000) as OSC:
for address, values in OSC.listen():
if address == b'/example':
print("got {} on /example".format(values))
else:
print("unknown address {}".format(address))

No, this server needs to be done, i didn't find the time to do it, and i didn't had the need for it either.
I assume it shouldn't be very hard to do, at least in a naive form, since there is no backpressure to handle in an udp stream (afaik), but because i didn't do any serious asyncio work yet, I might not build the most sensible api for it.

If you (or anyone) wants to try it, i should be able to help anyway, considering parsing is pretty much split from any network handling, only some parts from the OSCThreadServer might require adaptation for an asyncio usage, maybe creating a parent class containing the common logic, or extracting them in a different module to be used any other contexts if needed.