@nzfs TL;DR [oscparse] outputs integer arguments as numbers, not symbols. So, if you're getting a symbol, then it must be sent as a symbol -- so, check your nodejs code. It's probably applying an incorrect type tag.
My test:
This patch is a little simpler but it should still work with the multi-level command path:
And in SuperCollider, I wrote a quick function to hex-print the packet and send it. (The operative part for OSC transmission is n.sendMsg(*msg);
-- the rest of the function is only for printing.)
(
n = NetAddr("127.0.0.1", 57119);
f = { |msg|
// not necessary for sending -- just for printing
var osc = msg.asRawOSC;
osc.clump(32).do { |row|
// hex
row.do { |ch, i|
"% ".postf(ch.asHexString(2));
if(i % 8 == 7) { " ".post };
};
// chars
" ".post;
row.do { |ch, i|
ch = ch.asAscii;
if(ch.isPrint) { ch.post } { ".".post };
if(i % 8 == 7) { " ".post };
};
"".postln;
};
n.sendMsg(*msg);
};
)
And, run it:
f.(['/test', 123]); // integer
2F 74 65 73 74 00 00 00 2C 69 00 00 00 00 00 7B /test... ,i.....{
f.(['/test', 123.0]); // float
2F 74 65 73 74 00 00 00 2C 66 00 00 42 F6 00 00 /test... ,f..B...
f.(['/test', '123']); // symbol
2F 74 65 73 74 00 00 00 2C 73 00 00 31 32 33 00 /test... ,s..123.
Note the 10th byte, the type tag for the argument: i
, f
or s
.
For the integer, in Pd, I get "print: 123".
For the float, I get "print: 123".
For the symbol, I get "float: no method for '123'".
So... I'm 100% certain in the first case that it is being sent with an integer type tag, but that doesn't reproduce the problem. The only way I can reproduce the problem is by encoding the number as a symbol.
So my conclusion is that something is wrong on the sending side, not the receiving side.
hjh