Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

When Do I get the callbacks...



Hello,

I am working on some plugin technology and I have written a static library
that uses rendezvous and this library has to be integrated with the plugin
module. I am using CFNetServices. I have registered a service with one plugin
and I want to browse for that service over the network from other plugin using
Rendezvous.

Plugin 1 ---> Register for some Service.

Plugin 2 ---> Look for that service.


I have used the following code to register the service, The code is from the
Sample program.(CFMRendezvousSample ) Now the problem I am facing is the
Application for which I am writing the plugin gives me a callback for
idleloop() and I want to browse for the services during this. But what I have
found is till then the library hasn't received a callback that it registered
with CFNetServiceBrowserCreate. But if I postpone the browsing to some
othercallback the things are working fine. How do I solve the problem?

I think this is due to the fact that I am scheduling the callbacks with
Application Run Loop and that is asynchhronous.Am I right so if if just remove
the CFNetServiceBrowserScheduleWithRunLoop() the things should work fine. Also
I just want to see this once means I don't care if someone has just started
the service when I have finished my check. Am I on the right track? Pleas
advice.

Thanks
Sandeep Kanwal




/****************************************************************************
***********************************************************/
static void MyRegisterService(CFStringRef name, CFStringRef type, CFStringRef
domain, UInt32 port)

{

CFNetServiceClientContext clientContext = { 0, NULL, NULL, NULL, NULL };

CFStreamError error;


assert(name != NULL);

assert(type != NULL);

assert(domain != NULL);

gRegisteredService = CFNetServiceCreate(kCFAllocatorDefault, domain,
type,name, port);

assert(gRegisteredService != NULL);


// register the service asynchronously.

CFNetServiceSetClient(gRegisteredService, MyRegisterCallback,

&clientContext);


CFNetServiceScheduleWithRunLoop(gRegisteredService, CFRunLoopGetCurrent(),
kCFRunLoopCommonModes);

gTaskRegistered = CFNetServiceRegister(gRegisteredService, &error);


if (gTaskRegistered == FALSE) {

/* a problem happened with calling CFNetServiceRegister so unschedule

** the service from the runloop

*/

CFNetServiceUnscheduleFromRunLoop(gRegisteredService,

CFRunLoopGetCurrent(), kCFRunLoopCommonModes);

CFNetServiceSetClient(gRegisteredService, NULL, NULL);

CFRelease(gRegisteredService);

gRegisteredService = NULL;

//fprintf(stderr, "CFNetServiceRegister returned (domain = %d, error =
%ld)\n", error.domain, error.error);

}

else

//fprintf(stderr, "CFNetServiceRegister returned true\n");

return;

}







static Boolean MyStartBrowsingForServices(CFStringRef type, CFStringRef
domain) {

CFNetServiceClientContext clientContext = { 0, NULL, NULL, NULL, NULL };

CFStreamError error;

Boolean result;

assert(type != NULL);

assert(domain != NULL);

gServiceBrowserRef = CFNetServiceBrowserCreate(kCFAllocatorDefault,

MySearchBrowserCallback, &clientContext);

assert(gServiceBrowserRef != NULL);

CFNetServiceBrowserScheduleWithRunLoop(gServiceBrowserRef,
CFRunLoopGetCurrent(), kCFRunLoopCommonModes);

result = CFNetServiceBrowserSearchForServices(gServiceBrowserRef, domain,
type, &error);

if (result == false) {

// Something went wrong so lets clean up.

CFNetServiceBrowserUnscheduleFromRunLoop(gServiceBrowserRef,
CFRunLoopGetCurrent(), kCFRunLoopCommonModes);

CFRelease(gServiceBrowserRef);

gServiceBrowserRef = NULL;

//fprintf(stderr, "CFNetServiceBrowserSearchForServices returned (domain = %d,
error = %ld)\n", error.domain, error.error);

}

return result;

}
_______________________________________________
rendezvous mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/rendezvous
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.