Skip to content

Commit

Permalink
more OSC fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
spencersalazar committed May 16, 2014
1 parent f27c82b commit bab0e69
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/test/03-Modules/osc01.ck
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else

fun void send()
{
1::second => now;
1::samp => now;

OscOut xmit;
xmit.dest( "localhost", 6449 );
Expand Down
32 changes: 32 additions & 0 deletions src/test/03-Modules/osc02.ck
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

OscIn oin;
OscMsg msg;

6449 => oin.port;
oin.addAddress( "/test, i f s" );

spork ~ send();

oin => now;

oin.recv(msg);

if(msg.getInt(0) == 42 && Math.fabs(msg.getFloat(1) - 3.141) < 0.001 && msg.getString(2) == "hello!")
<<< "success" >>>;
else
<<< "failure" >>>;

fun void send()
{
1::samp => now;

OscOut xmit;
xmit.dest( "localhost", 6449 );
xmit.start( "/test" );
xmit.add(42);
xmit.add(3.141);
xmit.add("hello!");
xmit.send();
}


32 changes: 32 additions & 0 deletions src/test/03-Modules/osc03.ck
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

OscIn oin;
OscMsg msg;

6449 => oin.port;
oin.addAddress( "/test, ifs" );

spork ~ send();

oin => now;

oin.recv(msg);

if(msg.getInt(0) == 42 && Math.fabs(msg.getFloat(1) - 3.141) < 0.001 && msg.getString(2) == "hello!")
<<< "success" >>>;
else
<<< "failure" >>>;

fun void send()
{
1::samp => now;

OscOut xmit;
xmit.dest( "localhost", 6449 );
xmit.start( "/test" );
xmit.add(42);
xmit.add(3.141);
xmit.add("hello!");
xmit.send();
}


9 changes: 8 additions & 1 deletion src/ulib_opsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#endif


const std::string CK_OSC_TYPETAG_CHARS = "ifs";

struct OscMsg
{
std::string path;
Expand Down Expand Up @@ -168,7 +170,12 @@ class OscInServer
{
path = ltrim(rtrim(method.substr(0, comma_pos)));
nopath = FALSE;
type = ltrim(rtrim(method.substr(comma_pos+1)));

std::string dirty_type = method.substr(comma_pos+1);
type.clear();
for(int i = 0; i < dirty_type.size(); i++)
if(CK_OSC_TYPETAG_CHARS.find(dirty_type[i]) != std::string::npos)
type.push_back(dirty_type[i]);
notype = FALSE;
}
else
Expand Down

0 comments on commit bab0e69

Please sign in to comment.