Re: Mac OS X - Inter-Application Communications

2015-03-06 Thread Kevin Meaney

> On 6 Mar 2015, at 11:34, Dave  wrote:
> 
> Hi,
> 
>> I think you might need to provide some more info about your architecture and 
>> I also think you need to ask your questions in the xpc devforums list: 
>> https://devforums.apple.com/community/mac/coreos/xpc 
>>  because if you get an 
>> answer there it is more likely to be well informed.
> 
> Thanks Kevin, I’ll take a look at the XPC forum.
> 
>> I am a little confused by your terminology. I’d call an Application a 
>> process that a user interacts with (that displays the menu bar) but I 
>> wouldn’t call the four items listed above Applications.
> 
> 
> Yes, it is confusing and I think I called it this because it’s referred to as 
> a “Faceless Background Application” (FBA) in some places. I’ve just started 
> this project and I’m a little confused about some of the things I need to do 
> myself, but I think I have it clear in my head what is needed now, there are 
> two things that are needed:
> 
> 1.  Have some kind of background monitor (FBA?) that detects certain 
> conditions and when a trigger condition is met, send it to a regular Mac 
> Application (with a UI). There is no need for any of the Application(s) to 
> send anything to this FBA. 

This approach will awkward to implement because it is opposite to the way XPC 
is designed. The XPC design is intended for a process such as a (LoginItem, 
LaunchAgent, LaunchDaemon, XPC service) to provide a service, so when your GUI 
Application needs a task to be done that is provided by a service it sends that 
service a message which the service handles and then sends a reply back to the 
application using the connection initiated by the application.

It is likely possible to achieve the opposite goal by the application first 
sending a message to your monitor and the monitor keeps the connection open, 
details of how to achieve this other than just waiting to reply until the 
monitor trigger condition is met I can’t help with. 

> 
> 2.  Have some kind of “Service" that owns an SQLite database and allows other 
> applications to send read/write requests to it.

This would be a launch agent or a login item.

> 
> I was confusing the two before, probably because in the specification I have, 
> the two are shown as one unit.  At the moment I am concentrating on the 
> Monitor (1) above, as the database manager is not needed until further on in 
> the project.
> 
> Given the that I have two “applications” (for want of a better term) 
> LTWMonitor and LTWAppX, then on the face of it and ignoring any OS 
> requirements for the moment, this is what needs to happen:
> 
> LTWMonitor will be Launched when the User Logs.
> LTWMonitor will then launch LTWAppX as part of its initialisation. 
> LTWAppX will launch and do nothing, waiting for an “Event” from LTWMonitor.

If I was you I would consider putting your LTWAppX in the list of the users 
login items and after it starts it launches the monitor by sending the monitor 
a XPC request.

> 
> Once this has happened:
> 
> If LTWMonitor detects a Trigger condition, it will send it to LTWAppX.
> When LTWAppX receives the message from LTWMonitor, it take the appropriate 
> Actions (e.g. display an appropriate UI) for the message received.
> 
> Given this, should I be considering XPC for the UIMonitor? One concern I have 
> it what it needs to be very responsive and as far as I know XPC is the 
> fastest solution and is the preferred modern way of achieving this.

Performance wise I am happy with XPC but then your requirements may be 
different.

Kevin


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mac OS X - Inter-Application Communications

2015-03-06 Thread Dave
Hi,

> I think you might need to provide some more info about your architecture and 
> I also think you need to ask your questions in the xpc devforums list: 
> https://devforums.apple.com/community/mac/coreos/xpc 
>  because if you get an 
> answer there it is more likely to be well informed.

Thanks Kevin, I’ll take a look at the XPC forum.

> I am a little confused by your terminology. I’d call an Application a process 
> that a user interacts with (that displays the menu bar) but I wouldn’t call 
> the four items listed above Applications.


Yes, it is confusing and I think I called it this because it’s referred to as a 
“Faceless Background Application” (FBA) in some places. I’ve just started this 
project and I’m a little confused about some of the things I need to do myself, 
but I think I have it clear in my head what is needed now, there are two things 
that are needed:

1.  Have some kind of background monitor (FBA?) that detects certain conditions 
and when a trigger condition is met, send it to a regular Mac Application (with 
a UI). There is no need for any of the Application(s) to send anything to this 
FBA. 

2.  Have some kind of “Service" that owns an SQLite database and allows other 
applications to send read/write requests to it.

I was confusing the two before, probably because in the specification I have, 
the two are shown as one unit.  At the moment I am concentrating on the Monitor 
(1) above, as the database manager is not needed until further on in the 
project.

Given the that I have two “applications” (for want of a better term) LTWMonitor 
and LTWAppX, then on the face of it and ignoring any OS requirements for the 
moment, this is what needs to happen:

LTWMonitor will be Launched when the User Logs.
LTWMonitor will then launch LTWAppX as part of its initialisation. 
LTWAppX will launch and do nothing, waiting for an “Event” from LTWMonitor.

Once this has happened:

If LTWMonitor detects a Trigger condition, it will send it to LTWAppX.
When LTWAppX receives the message from LTWMonitor, it take the appropriate 
Actions (e.g. display an appropriate UI) for the message received.

Given this, should I be considering XPC for the UIMonitor? One concern I have 
it what it needs to be very responsive and as far as I know XPC is the fastest 
solution and is the preferred modern way of achieving this.

The other problem is that I am under NDA and I can’t reveal too much about the 
product.

In the past I’ve used an official “Apple Developer Support Incident” for things 
like this and since the company I am working for has a few of these as part of 
their Developer Membership i might as well use one. I was wondering if this 
type of request is still handled? If so, then I think it would be worth using 
one for this as it’s fundamental to the whole project.

All the Best
Dave

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mac OS X - Inter-Application Communications

2015-03-05 Thread Kevin Meaney
On 5 Mar 2015, at 19:29, Dave  wrote:
> 
> Hi,
> 
> I’m really confused as it what type of a Application I need to create, from 
> reading the "Daemons and Services Programming Guide", it lists:
> 
> Login Item.
> XPC Service.
> Launch Daemon.
> Lauch Agent.
> 
> On the face of it, a LogIn Item seems to be what i am looking for, but its 
> unclear (at least to me) if I can host an XPC service inside this type of 
> application?

I think you might need to provide some more info about your architecture and I 
also think you need to ask your questions in the xpc devforums list: 
https://devforums.apple.com/community/mac/coreos/xpc 
 because if you get an 
answer there it is more likely to be well informed.

I am a little confused by your terminology. I’d call an Application a process 
that a user interacts with (that displays the menu bar) but I wouldn’t call the 
four items listed above Applications.

The four items you listed above can all communicate using the XPC interprocess 
communication protocol but I doubt you’ll be able to install an XPC service 
within any of them and work with that as well. 

> 
> I noticed in XCode 6, you can create an XPC Service Application, so I created 
> one, compiled it and placed the Application file in Startup Items, it seems 
> to load up ok, at least I get a terminal window opened pointing to the App’s 
> bundle.
> 
> I am not intending on Sandboxing this.

I’m fairly certain that the XPC Service requires the Application that contains 
it has to be sandboxed. I would recommend for confirmation that you follow this 
up on the devforums list linked to above.

> 
>> I think as long as the OP is not intending to sandbox then using a 
>> LaunchAgent or LoginItem for communicating with a XPC will work but I doubt 
>> that using an XPC service will do this.
> 
> I’m not sure what you mean by this? 

OP is Original Poster which is you, and later on in that sentence I confused 
things. Let me rephrase:

I think as long as Dave is not intending to sandbox his Application then using 
a LaunchAgent or LoginItem for communicating via XPC will work but I doubt that 
an XPC service will do this.

I struggled badly with this about 20 months ago. The documentation is either 
directed at people writing XPC services in sandboxed applications or written 
for unix developers used to writing daemons and describes how to achieve 
similar goals on OSX using language unix developers would understand, whereas 
writing LaunchAgents or LoginItems fit somewhere between the two. Persistence 
does win out. I wish I could be more certain in my replies but 20 months is 
long enough for certain details to be forgotten.

Kevin

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mac OS X - Inter-Application Communications

2015-03-05 Thread Dave
Hi,

I’m really confused as it what type of a Application I need to create, from 
reading the "Daemons and Services Programming Guide", it lists:

Login Item.
XPC Service.
Launch Daemon.
Lauch Agent.

On the face of it, a LogIn Item seems to be what i am looking for, but its 
unclear (at least to me) if I can host an XPC service inside this type of 
application?

I noticed in XCode 6, you can create an XPC Service Application, so I created 
one, compiled it and placed the Application file in Startup Items, it seems to 
load up ok, at least I get a terminal window opened pointing to the App’s 
bundle.

I am not intending on Sandboxing this.

> I think as long as the OP is not intending to sandbox then using a 
> LaunchAgent or LoginItem for communicating with a XPC will work but I doubt 
> that using an XPC service will do this.

I’m not sure what you mean by this? 

Cheers
Dave


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mac OS X - Inter-Application Communications

2015-03-03 Thread Kevin Meaney
On 3 Mar 2015, at 16:56, Kyle Sluder  wrote:
> 
> On Tue, Mar 3, 2015, at 05:50 AM, Dave wrote:
>> I have the high level flow worked out now, but I’m not sure of what to
>> use in order to Send Events between my Applications and whether I need to
>> have one App (e.g. the Background App or another dedicated
>> “DatabaseManager” Background App) solely responsible for accessing the
>> database so as to ensure it’s in sync and that updates are run in the
>> correct order.
>> 
>> I was thinking of using IPC/XPC as a means of doing this and I’m reading
>> “Daemons and Services Programming Guide”.
>> 
>> Any advice or suggestions as to best way of achieving this would be
>> greatly appreciated.
> 
> The modern way to do this would be to have an XPC service exclusively
> own the database, and have all other applications talk to the XPC
> service to request data.

I think as long as the OP is not intending to sandbox then using a LaunchAgent 
or LoginItem for communicating with a XPC will work but I doubt that using an 
XPC service will do this. You might just be able to make it work using XPC 
services for example if you have one all encompassing sandboxed App which 
contains multiple XPC services that do different tasks.

You might find the WWDC session 308 from 2012 useful.

I’ve an example project on github for a launch agent that uses XPC. I’m sorry I 
haven’t updated since implementing in Xcode 5. 
https://github.com/SheffieldKevin/LaunchAgent

Kevin



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mac OS X - Inter-Application Communications

2015-03-03 Thread Kyle Sluder
On Tue, Mar 3, 2015, at 05:50 AM, Dave wrote:
> I have the high level flow worked out now, but I’m not sure of what to
> use in order to Send Events between my Applications and whether I need to
> have one App (e.g. the Background App or another dedicated
> “DatabaseManager” Background App) solely responsible for accessing the
> database so as to ensure it’s in sync and that updates are run in the
> correct order.
> 
> I was thinking of using IPC/XPC as a means of doing this and I’m reading
> “Daemons and Services Programming Guide”.
> 
> Any advice or suggestions as to best way of achieving this would be
> greatly appreciated.

The modern way to do this would be to have an XPC service exclusively
own the database, and have all other applications talk to the XPC
service to request data.

--Kyle Sluder

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com