Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

louiecaulfield
Copy link

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.

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
Copy link
Owner

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:
Copy link
Owner

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):
Copy link
Owner

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):
Copy link
Owner

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)

@attwad attwad deleted the branch attwad:master December 22, 2024 17:07
@attwad attwad closed this Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants