the received packet may be a message or a bundle
This commit is contained in:
parent
31ec3ade78
commit
0bd30d1151
|
@ -113,11 +113,28 @@ void Receiver::scheduleBundle(const std::shared_ptr<Bundle> msg) const
|
|||
*/
|
||||
void Receiver::rxPacket(std::shared_ptr<bufferstream> buffer) const
|
||||
{
|
||||
while (buffer->good()) {
|
||||
auto msg = std::make_shared<Message>();
|
||||
auto packet = [&](std::shared_ptr<Message> msg)
|
||||
{
|
||||
msg->iStream(buffer);
|
||||
if (!buffer->fail())
|
||||
dispatch(msg);
|
||||
};
|
||||
|
||||
while (buffer->available() && buffer->good())
|
||||
{
|
||||
/// > \cite Spec10 The contents of an OSC packet must be either an OSC Message or
|
||||
/// > an OSC Bundle. The first byte of the packet’s contents unambiguously
|
||||
/// > distinguishes between these two alternatives.
|
||||
switch (buffer->peek()) {
|
||||
case '/':
|
||||
packet(std::make_shared<Message>());
|
||||
break;
|
||||
case '#':
|
||||
packet(std::make_shared<Bundle>());
|
||||
break;
|
||||
default:
|
||||
buffer->setstate(std::ios::failbit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue