Tagged: unity hot sex anton
May 5, 2011 at 5:14 pm #5154Brian ChasalowParticipant
I’m having a weird issue with my Syphon Unity implementation. It would appear as though my SyphonServerDirectory array count erroneously appears to have a value of 0 on application start. After my application has run for a few frames, it will begin to report the correct # of syphon servers available. Is there a way to jumpstart the initialization, if it is not initialized yet? I’m assuming the SyphonServerDirectory plugin takes a moment to initialize, but perhaps if i can force initialization, i won’t have this issue (unless i’m way off base)
this is the function that returns 0 for a few frames, before it starts returning a correct value: (hack-n-slash obj-c, be warned)
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
serversArray = [[SyphonServerDirectory sharedDirectory] servers];
return [serversArray count];
}May 5, 2011 at 10:09 pm #5155vadeKeymaster
This is *probably* a notification delay in NSDisttributedNotification. Basically clients and servers post notifications to the operating system, which in turn notifies the app that a server, or a client has appeared and requests a list of available resources.
I dont know what the normal delay is in the client finding a server. That is a good question. You need *immediate* response?
You could try making a call to [SyphonServerDirectory sharedDirectory] on level load, and keep a reference to it (so the singleton object is already initted in your app), and only call [serversArray count] every frame. You might be seeing the startup cost of initially making the first and only instance of the singleton. Try making the singleton prior to your first frame being called?
That might help shave some time off. that said, NSDistributedNotification is not amazingly speedy, and object creation is *very* optimized, so id be surprised if creating the singleton SharedDirectory prior to level load made a giant difference.May 6, 2011 at 2:40 pm #5156bangnoiseKeymaster
It’s not an error, it’s a deliberate feature – you don’t want your code to wait for remote applications to respond.
There’s nothing you can do to speed the process up (vade’s suggestion won’t help as the framework already does that for you when it’s loaded). Generally I’d avoid polling – register for the NSNotification SyphonServerDirectory posts and you’ll receive a notification as soon as each server is discovered (or disappears, changes its name).May 6, 2011 at 3:07 pm #5157Brian ChasalowParticipant
oh. that gave me an idea, tom- thanks. since i’m already registered for the that notification, i can just wait til i receive the very first notification to switch my bool that says ‘my directory is loaded’
- You must be logged in to reply to this topic.