-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse all OscMessages available within a packet's datagram #175
Conversation
A datagram can contain multiple OscMessages. This patch adds a field to an OscMessage containing the remaining (tail) bytes of its datagram. The OscPacket constructor continues to parse OscMessages from a datagram until all bytes are consumed.
self._messages.append(TimedMessage(now, msg)) | ||
if msg._dgram_tail is None: | ||
break | ||
dgram = msg._dgram_tail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please provide a readonly property instead of accessing the _dram_tail from another class
while(True): | ||
msg = osc_message.OscMessage(dgram) | ||
self._messages.append(TimedMessage(now, msg)) | ||
if msg._dgram_tail is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. you can just use if not msg.dgram_tail:
, no need to compare against None
@@ -68,7 +68,14 @@ def __init__(self, dgram: bytes) -> None: | |||
key=lambda x: x.time, | |||
) | |||
elif osc_message.OscMessage.dgram_is_message(dgram): | |||
self._messages = [TimedMessage(now, osc_message.OscMessage(dgram))] | |||
self._messages = [] | |||
while(True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. just while True:
without parenthesis
@@ -68,7 +68,14 @@ def __init__(self, dgram: bytes) -> None: | |||
key=lambda x: x.time, | |||
) | |||
elif osc_message.OscMessage.dgram_is_message(dgram): | |||
self._messages = [TimedMessage(now, osc_message.OscMessage(dgram))] | |||
self._messages = [] | |||
while(True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also base the condition of that while loop on the presence of the msg.dgram_tail, it'd read better, something like:
while msg.dgram_tail:
msg = osc_message.OscMessage(dram)
self._messages.append(TimedMessage(now, msg)
A datagram can contain multiple OscMessages. This patch adds a field to an OscMessage containing the remaining (tail) bytes of its datagram. The OscPacket constructor continues to parse OscMessages from a datagram until all bytes are consumed.