Le 7 déc. 2010 à 17:56, Keary Suska a écrit : > On Dec 7, 2010, at 9:28 AM, Jerry Krinock wrote: > >> My application needs to communicate with my associated Internet Plugin (a >> bundle that runs in web browsers). For example, here is one sequence: >> >> • App sends a "hello" to the plugin. >> • Plugin processes "hello", responds to app, indicating that it is installed >> and alive. >> • App sends up to a few hundred KB to the plugin. >> • Plugin sends a few tens of KB back to the app. >> >> This may happen several times a day. >> >> Apple documentation seems to be steering me into Distributed Objects (DO) >> for this. But DO are so complicated! There are vended objects, proxies, >> connection configurations, etc. Looks like I'd have to study it for a week >> or more. Since the web browser talks in JSON-encoded strings anyhow, I >> don't need to send any Cocoa objects; just bytes are fine. >> >> Trying to use what I know, I've been using NSDistributedNotificationCenter >> to send little messages, and when there is significant data, the sender >> writes the data to a temporary file and sends the temporary file's path as >> userInfo in the notification. Upon receiving the notification, the receiver >> reads the file; end of story. >> >> This seems to work OK, except for the minor annoyance of distributed >> notifications always arriving on the main thread and needing to be >> forwarded. I was thinking that maybe I should use NSPort since I've had >> some experience with it, but NSPort documentation advises that "You should >> implement interapplication communication using distributed objects whenever >> possible and use NSPort objects only when necessary." Why is that? >> >> How should I be doing this? > > If the data you are exchanging is fairly lightweight I can recommend shared > memory segments. Decidedly un-Cocoa-like but very fast and reliable. DO is > heavy and distributed notification are unreliable (per the documentation). In > both cases you may need code to ensure reliability. >
CFMessagePort is fine too to simply pass data from one process to an other. And it is far more cocoa-like as it is CF based. And as it is a CFRunLoop source, it's easy to decide which thread send and receive messages. -- Jean-Daniel _______________________________________________ Cocoa-dev mailing list ([email protected]) 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]
