I'm trying to get Distributed Objects and Bonjour to work together.
I've found various examples of these two items working
independently, but I cannot seem to get them to work together.
I'll assume that the two methods you've posted are from different
objects, since they both assign to a "connection" ivar. If not, you
have big problems.
TI can broadcast and browse my Bonjour service and I setup my D-O
system like this:
In the client, I browse for services and I have an NSMutableArray
of NSNetService's that are of the service type _tindex._tcp. When
somebody wants to connect to the server this method is executed (by
clicking on a button):
This sounds reasonable...
- (IBAction)connectToServer: (id)sender
{
id proxy;
NSData *addy;
This above is the problemed code. I have no idea why this isn't
working. When I uncomment the two lines above, then I get a crash.
I've tried searching for so many examples, but can't find anything
that works.
Here again, you need to retain connection if it's an ivar. Also, you
need to run the call to -rootProxy inside an exception handler, and
catch any exceptions raised (timeouts are common).
Your NSLog of proxy will likely crash since you didn't initialize the
local variable to nil, as well. Having netService as an ivar
assigned here doesn't make sense, either.
If you're interested in sample code, we added a sharing feature to
BibDesk recently that uses DO over Bonjour for iTunes/iPhoto-style
sharing, and it seems to work well.
This stuff is all BSD licensed; there aren't many (any?) DO/Bonjour
sample code projects, so maybe something here will be useful to you,
although the full project is moderately complicated. You can download
and try it for yourself to see how it works, and bug reports are
welcome, of course.
--
Adam
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden