On Sep 25, 2008, at 16:07 , Karan, Cem (Civ, ARL/CISD) wrote:

I've got a class that acts like a super-lightweight server within my program. It listens for incoming packets of information, decodes them, and then tells the rest of my code that something changed. So far, this sounds like a job for NSNotificationCenter, except that I'm getting the packets by UDP, and don't want to tell all the listeners about every single update that happens; it would be better to coalesce them into one notification and notify them when the run loop is idle. OK, so this sounds perfect for NSNotificationQueue with (NSNoticationCoalescingOnName|NSNotificationCoalescingOnSender) as the options. The problem is that I want to send all the data along in the user dictionary. How is that coalesced? Note that I want ALL the data I'm putting in the dictionary, not just the last user dict.

You could create a method on your server class that returns the all the data as one NSData object. So, create a mutable data object in your server object and every time you get a UDP packet, add that to the data and then post a notification. When the notification gets received, the notified object messages your server object and retrieves all the data that way. Just make sure that the retrieve call is properly synchronized or that everything is running on the same thread
and you should have no problems. That's the way I would do it, anyway.

Jason

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to