#include <oscpkt.hh>
Public Member Functions | |
PacketWriter & | init () |
PacketWriter & | startBundle (TimeTag ts=TimeTag::immediate()) |
PacketWriter & | endBundle () |
PacketWriter & | addMessage (const Message &msg) |
bool | isOk () |
ErrorCode | getErr () |
uint32_t | packetSize () |
char * | packetData () |
Assemble messages into an OSC packet. Example of use:
PacketWriter pkt; Message msg; pkt.startBundle(); pkt.addMessage(msg.init("/foo").pushBool(true).pushStr("plop").pushFloat(3.14f)); pkt.addMessage(msg.init("/bar").pushBool(false)); pkt.endBundle(); if (pkt.isOk()) { send(pkt.data(), pkt.size()); }
oscpkt_demo.cc, and oscpkt_test.cc.
PacketWriter& oscpkt::PacketWriter::addMessage | ( | const Message & | msg | ) | [inline] |
insert an Osc message into the current bundle / packet.
PacketWriter& oscpkt::PacketWriter::endBundle | ( | ) | [inline] |
close the current bundle.
bool oscpkt::PacketWriter::isOk | ( | ) | [inline] |
the error flag will be raised if an opened bundle is not closed, or if more than one message is inserted in the packet without a bundle
char* oscpkt::PacketWriter::packetData | ( | ) | [inline] |
return the bytes of the osc packet (NULL if the construction of the packet has failed)
uint32_t oscpkt::PacketWriter::packetSize | ( | ) | [inline] |
return the number of bytes of the osc packet -- will always be a multiple of 4 -- returns 0 if the construction of the packet has failed.
PacketWriter& oscpkt::PacketWriter::startBundle | ( | TimeTag | ts = TimeTag::immediate() |
) | [inline] |
begin a new bundle. If you plan to pack more than one message in the Osc packet, you have to put them in a bundle. Nested bundles inside bundles are also allowed.