Bonjour Greatness

Well after a fun and exciting day, it was pointed out to me that I could use bonjour to automatically discover roku devices and make the setup process even easier.

So I went off on my web travels and started messing about, seeing how bonjour worked and how I could use it in my app. When I final found the “good-stuff”, I was amazed at the simplicity of the code required:

NSNetServiceBrowser *browser = [[NSNetServiceBrowser alloc] init];
[browser setDelegate:self];
[browser searchForServicesOfType:@"_roku-rcp._tcp." inDomain:@"local."];

Basically, this tells the app to find any roku services on the local network, all in 3 lines!!! And for the delegate method:

- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing {
if([aNetService getInputStream:&iStream outputStream:&oStream]) {
//open streams
} else {
//close streams
}
}

All the hard work of fetching streams, finding and setting port and host/ip data is all done for you. Once the streams have been opened and delegated your ready to go :D

Comments (1)

Pat MooreMarch 14th, 2009 at 11:58 am

OH MY GOD!!!!!!!!!!! Yes I am shouting that out. Your application downloaded and installed on the computer (iPhone). I then walked into my sitting room where I have the Roku Soundbridge set up. The iPhone picked it up automatically (I know you said it would but still!!!). From that moment on it was a dream. I was waiting for something like this. Amazing piece of work. Thank you so much. I would have paid more!!!!!!!!!

Leave a comment

Your comment