Callback/Communication with cocoa application

12 views
Skip to first unread message

tomrei

unread,
Nov 23, 2009, 4:22:44 AM11/23/09
to Cappuccino & Objective-J
Hi there!

I'm currently working on an application that is a combination of a
cappuccino app (for the browser UI) and a cocoa application running in
the background (for all the things that can't be done with javascript:
saving files, ...)

Is there a way to communicate from the cocoa app to my cappuccino app?
For example: I ask the cocoa app to fetch me a file and save it to a
place where i can access it from my cappuccino app. How can the cocoa
app send the cappuccino-app a message when this task is done?

Thanks for your help!
Tom

Francisco Tolmasky

unread,
Nov 23, 2009, 7:07:45 PM11/23/09
to Cappuccino & Objective-J
Is this app an app you plan on running locally on the user's computer?
Either way the response is kind of the same: You need a simple server
that can listen to requests and perform these actions. This is
basically what we do in Atlas to do exactly this. So, if you were
saving a file, you might do something like:

send-POST-request to http://localhost/something/filename

The POST handler on the server then saves the file appropriately on
the system. In your case I imagine this server would be written in
ObjC/Cocoa.

Hope this helps,

Francisco

tomrei

unread,
Nov 24, 2009, 11:09:54 AM11/24/09
to Cappuccino & Objective-J
Thanks for your answer Francisco...
Yes this app should be running locally but in the browser-window (so a
little bit different than Atlas). OK - the communication from the
webApp to the CocoaApp could be done in the way you suggested, good
idea.

BUT my real question was about the communication in the other
direction, so how can the Cocoa/BackgroundApp (your server)
communicate to the webApp. I would like to be able to notify the
WebApp when e.g. a progress from the backgroundApp is ready and the
WebApp should update it's view (without having to reload the whole
webApp).
I hope it's more clearly what I'm searching for.

By the way: I'm a student from Austria and thinking about doing my
Master thesis with Cappuccino and Atlas because I really like it - so
thank you so much for the great work you guys are doing!!

On Nov 24, 1:07 am, Francisco Tolmasky <franci...@280north.com> wrote:
> Is this app an app you plan on running locally on the user's computer?
> Either way the response is kind of the same: You need a simple server
> that can listen to requests and perform these actions. This is
> basically what we do in Atlas to do exactly this. So, if you were
> saving a file, you might do something like:
>
> send-POST-request tohttp://localhost/something/filename

David K. Hess

unread,
Nov 24, 2009, 11:55:03 AM11/24/09
to objec...@googlegroups.com

The Javascript security model is going to get in the way of most of
the obvious ways of doing this (communicating through a file on the
local disk for example).

However, you might be able to do something using HTML 5's database
feature if you can hook your native app up to the same database and
poll for changes in it from the Cappuccino side - at least the Nokia
(Trolltech) folks suggest this approach when using Qt and WebKit.

So, that implies that somewhere in WebKit you should be able to get
access to the database from the Cocoa side.

Dave
> --
>
> You received this message because you are subscribed to the Google
> Groups "Cappuccino & Objective-J" group.
> To post to this group, send email to objec...@googlegroups.com.
> To unsubscribe from this group, send email to objectivej+...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/objectivej?hl=en
> .
>
>
>

Antonio Salazar Cardozo

unread,
Nov 24, 2009, 12:16:03 PM11/24/09
to objec...@googlegroups.com
The other option is a long-polling, comet-style setup that lets you get pushed updates from the server. None of the usual concerns about resource consumption apply for you, since you'll only have the one client talking to the server. I believe there are mails in the list regarding an example app communicating with the Tornado web server (http://www.tornadoweb.org/documentation), so do a quick search and see.
Antonio

Tys von Gaza

unread,
Nov 24, 2009, 12:52:29 PM11/24/09
to Cappuccino & Objective-J
There are a couple other options for long polling that are worth
investigating:
- Ruby (MacRuby?) and Juggernaut
- Nginx Push Module - http://pushmodule.slact.net/
- Node.js http://wiki.github.com/ry/node
- Your own long polling ObjC server, as you probably only need to
worry about a single client the above are all pretty heavy weight.
- Build a simple in queue which will empty 99% of the time.
- ObjC server that won't send any data to the client until there is
something in the queue. Other wise it will "hang" the connection, not
sending any data.
- Have your Cappuccino app connect to the ObjC server, if there is
nothing in the queue, it will also "hang" waiting for data.
- When you add something to the queue, send it to the client
(Cappuccino). This probably should be javascript that can be eval'ed.
- The Cappuccino client gets the data and closes the connection,
then in your Cappuccino delegate reconnect. Repeat the above.
- The queue just lets you throw a bunch of ops at your Cappuccino
app at once, so each time it reconnects it will get the next operation
and reconnect, etc until the queue is empty.

Tys

On Nov 24, 10:16 am, Antonio Salazar Cardozo <savedfastc...@gmail.com>
wrote:
> >> For more options, visit this group athttp://groups.google.com/group/objectivej?hl=en

Maz

unread,
Nov 24, 2009, 3:15:22 PM11/24/09
to Cappuccino & Objective-J
You could probably use Titanium (http://www.appcelerator.com/). Also,
if you're just targeting the mac, you could use a WebView with a
WebScriptObject in the cocoa app.

On Nov 24, 12:52 pm, Tys von Gaza <t...@tvg.ca> wrote:
> There are a couple other options for long polling that are worth
> investigating:
> - Ruby (MacRuby?) and Juggernaut
> - Nginx Push Module -http://pushmodule.slact.net/
> - Node.jshttp://wiki.github.com/ry/node

Marijn Huizendveld

unread,
Nov 24, 2009, 3:18:51 PM11/24/09
to objec...@googlegroups.com
Am I missing the point here, why would one use cappuccino if the target is Mac only... Wouldn't it be simpler to write a native app (i.e. Objective-C Cocoa) in that case..?

Kindest regards,

Marijn
Reply all
Reply to author
Forward
0 new messages