Open zacksettel opened 1 year ago
It's not extensible at the moment. At least, I should remove sealed
from OscClient
/OscServer
.
Is there some reason the signature isn't handled dynamically? Such as:
public void Send(string address, params object[] data)
{
if (data == null)
{
Send(address);
return;
}
_encoder.Clear();
_encoder.Append(address);
string format = ",";
foreach (object o in data)
{
if (o is string) format += "s";
else if (o is int) format += "i";
else if (o is float) format += "f";
}
_encoder.Append(format);
foreach (object o in data)
{
if (o is string) _encoder.Append((string)o);
else if (o is int) _encoder.Append((int)o);
else if (o is float) _encoder.Append((float)o);
}
_socket.Send(_encoder.Buffer, _encoder.Length, SocketFlags.None);
}
Excellent idea. That would make for one less dependency on my forked version (I wrote the same method in my forked version).
It would be great to be able to extend the class
OscClient
in order to create additionalOscClient.Send()
method signatures. For example, I often need to send the following type of OSC message:public void Send(string address, string str, float data1, float data2, float data3)
For some time now, I have used a forked version of
OscJack
, but it seems that if there was a way for me to extend the OscClient class (currently sealed), that would be the best (I rely several different method signatures forOscClient.Send()
Or maybe there's another approach beside the fork?