Hello all,
So, I am in the midst of adding TUIO event generation to the BBTouch code base. For anyone who doesnt know, TUIO is a subset of OSC (open sound control) commands, and is sent using the OSC standard.
Sooo... to this effect, i started researching all the various OSC libs out there, and there are a few, and they are all pretty good. However, in the spirit of this project (ie an all-cocoa multi-touch thing), and in an effort to learn more about the OSC protocol, i decided to start over from scratch.
That was a few days ago, and here is a new OSC implementation in not-so-pure cocoa/objc. There is a bunch of POSIX and C stuff in there to deal with the sockets and the bit-level manipulation of the data. but that is all abstracted away into some nice objects.
here is some sample code for making an OSC listener: (aka a server)
BBOSCListener* anOSCListener = [BBOSCListener defaultListenerOnPort:4556];
that's it. the listener will use the default dispatch delegate to handle the messages coming in, and there you go. (note: be sure to retain your listener if you use the 'easy' method above)
and to send messages? like so:
BBOSCSender* anOSCSender =
[BBOSCSender senderWithDestinationHostName:@"localhost" portNumber:4556];
if (![anOSCSender sendOSCPacket:newMessage]) {
NSLog(@"Oh Noes!!");
}
that's it.
generating messages and bundles is also simple:
BBOSCMessage * newMessage =
[BBOSCMessage messageWithBBOSCAddress:
[BBOSCAddress addressWithString:@"/test/1/groovy"]];
[newMessage attachArgument:
[BBOSCArgument argumentWithString:@"Testing!!"]];
[newMessage attachArgument:
[BBOSCArgument argumentWithInt:12]];
and bundles are similar.
Anyhooo.. the code is available here:
http://code.google.com/p/bbosc/
It is all commented nicely so you should be able to re-use it pretty easily.
A few notes: First, it should probably be a framework, but for now it is just a collection of files. Also, I havent gotten around to building a nice message dispatch system. so for now, if you want to use the code to build a server, you will have to implement your own dispatch. I built it originally to be the client code for BBTouch TUIO events, but it seemed silly not to build the listener stuff as well, so i built that in. (sans dispatch). I am going to add the sending stuff to bbtouch, then i will come back and add a nice dispatch module into BBOSC.