← Back

ofxSmartOscSender

github.com/2bbb/ofxSmartOscSender · @2bbb
OF 0.11 Web/Networking

i wanna send with `send("/address", foo, bar, buzz)`

10 2 Last commit 3y ago Created 11y ago

README

ofxSmartOscSender



i wanna send with send("/address", foo, bar, buzz)

Notice



this addon uses C++11, require of0.9.0~

if you use master branch and causes an error, please pull latest commit.

Dependencies



ofxOsc

API



ofxSmartOscSender



sending OSC



void send(const std::string &address, const Args & ... args); Args : arithmetic type, string, ofBuffer

default mode is use sendAsSimpleFormat. you can change to use sendAsStrictFormat with setUsingStrictFormat(true);.

void sendAsSimpleFormat(const std::string &address, const Args & ... args);

send arithmetic type as following mapping.

arg typeosc type
integralint32
floating pointsfloat
void sendAsStrictFormat(const std::string &address, const Args & ... args);

send arithmetic type as following mapping.

arg typeosc type
boolbool
charchar
unsigned charint32
shortint32
unsigned shortint32
intint32
unsigned intint64
longint64
unsigned longint64
long longint64
unsigned long longint64
floatfloat
doubledouble

stream operator



ofxSimpleOscSender &operator<<(Type t)

add osc argument that allowed type.

argument follows rule as strict/simple mapping is gave by setUsingStrictFormat.

ofxSimpleOscSender &operator<<(Terminator &t)

only allow bbb::send.

# example.



	ofxOscSender sender;
	...
	sender("/address") << 1 << 2 << bbb::send;
	sender << 1 << 2 << bbb::send("/address"); // same as above!
	sender("/hogehoge") << 1 << 2 << bbb::send("/address"); // overwrite address with argument of send. so, same as above!


<a name="option_setting">option setting</a>



void setUsingStrictFormat(bool bStrict); bool getUsingStrictFormat() const;

default is false.

if you want to use OSC with Cycling'74 Max, you should be use setUsingStrictFormat(false) (so it is default!).

void setSendingWithWrapInBundle(bool wrapInBundle); bool getSendingWithWrapInBundle() const;

default is true.

and all ofxOscSender's public method

ofxMultiOscSender



void addTarget(const std::string &host, int port); void removeTarget(const std::string &host, int port);

and all ofxSmartOscSender's public method

extend operator<< of ofxOscMessage



you can extend with

using namespace bbb::ofxOscMessageStreamOperators;
using namespace bbb::ofxOscMessageStrictStreamOperators;
using namespace bbb::ofxOscMessageSimpleStreamOperators;


ofxOscMessageStreamOperators is alias of ofxOscMessageSimpleStreamOperators.

if you want to use OSC with Cycling'74 Max, you should be use ofxOscMessageSimpleStreamOperators

example.



	ofxOscMessage m;
	m.setAddress("/address");
	m << 1 << "hoge" << 14.0f;
	// means:
	// m.addInt32Arg(1);
	// m.addString("hoge");
	// m.addFloatArg(14.0f);


see:
ofxOscMessageStreamOperator.h

extend operator<<(std::ostream, const ofxOscMessage &)



you will get ofLogNotice() << m; with #include "ofxOscMessageOstreamExtention.h"

ofxOscMessageInputStream (has operator>>)



ofxOscMessageInputStream(m) >> x >> y >> str;
oscin(m) >> x >> y >> str; // same above


or

oscin in(m);
in >> x;
in >> y;
in >> str;


Update history



2016/03/15 ver 0.0.6 release



fix problem: duprecated symbol fix simple mistake about README. omg...

2016/01/04 ver 0.0.5 release



add ofxOscMessageInputStream.h

2015/11/16 ver 0.0.4 release



add ofxOscMessageOstreamExtention.h

2015/11/15 ver 0.0.3 release



fix wrong namespace alias add stream operator for ofxSimpleOscSender/ofxMultiOscSender tiny bugifxes

2015/11/14 ver 0.0.2 release



renamed from ofxSimpleOscSender (suggested from yusuketomoto) add set/getUsingStrictFormat, set/getSendingWithWrapInBundle extend operator<< for ofxOscMessage in ofxOscMessageStreamOperator.h. (idea from satoruhiga) add example

2015/11/12 ver 0.0.1 release



initial

License



MIT License.

Author



2bit [ISHII 2bit Program Office]

At the last



Please create a new issue if there is a problem. And please throw a pull request if you have a cool idea!!

Get this addon

HTTPS
SSH