java - Communication between a desktop app and a web app? - Stack Overflow

I'm interested in having a desktop application send messages to a web app. Specifically, the deskt

I'm interested in having a desktop application send messages to a web app. Specifically, the desktop app, written in Java, needs to send messages to a Javascript function that will be running in a browser. The messages only need to be sent one way. Also, both programs will be running on the same local machine. I can set up a local development server if necessary.

I'm new to networking and web development and I have no idea how to approach this problem. Can anyone offer any suggestions?

I'm interested in having a desktop application send messages to a web app. Specifically, the desktop app, written in Java, needs to send messages to a Javascript function that will be running in a browser. The messages only need to be sent one way. Also, both programs will be running on the same local machine. I can set up a local development server if necessary.

I'm new to networking and web development and I have no idea how to approach this problem. Can anyone offer any suggestions?

Share Improve this question edited Aug 9, 2012 at 0:02 Oskar Eriksson 2,64119 silver badges33 bronze badges asked Dec 14, 2011 at 23:12 dB'dB' 8,35016 gold badges61 silver badges108 bronze badges 3
  • 2 What is the exact functionality you want to have? – Thorbjørn Ravn Andersen Commented Dec 14, 2011 at 23:14
  • I'm trying to use some of the functionality of the Web Audio API. I want to do some soundfile playback and audio processing in the browser, but have it controlled by the desktop app.(chromium.googlecode./svn/trunk/samples/audio/index.html) – dB' Commented Dec 14, 2011 at 23:23
  • The hybrid desktop/web app scheme is actually a temporary solution. Eventually I plan to have the whole app running in the browser, but during development I'll need to have some legacy code running on the desktop before I can find time to port it to Javascript. – dB' Commented Dec 14, 2011 at 23:32
Add a ment  | 

4 Answers 4

Reset to default 3

I think the appropriate way to do that (if not the only way) would be to go through a server both apps talks to

The enterprise architecture way I remend you do is:

  1. Put the mon information into a webservice.
  2. The website sends information, possibly via ajax or by navigating to a different URL or doing a form POST to the webservice.
  3. The desktop app will start up and will subscribe to the webservice. The webservice will notify the desktop app once it has an update. (note that the desktop app, might need to poll for updates).

That approach is how services such as flikr, twitter etc use.

The light weight (ie smaller architecture) way of hacking this is to make your website have an RSS feed that your desktop app subscribes to. The desktop app gets updated via the RSS feed.

That approach is how services such as news websites will send updates to readers. See google reader as an example RSS client. RSS has an adavantage of supporting generic rss consumers like MS outlook or google reader from the start, where as webservices are likely to be more flexible and cleaner in the long run.

why does the desktop app need to talk to javascript? What is it you are actually trying to do? Send or receive data to or from a database? Run some business logic on the web app? These things are typically done from a desktop app to a website using soap or rest.

is the browser embedded somehow in the desktop app? Or could is it just running as a separate process? It seems like audio processing should really run in the desktop app.

However, assuming that the browser is running as a separate app, you should be able to send messages to the browser through the query string. The desktop app could fire up the browser, point it to a url and pass some parameters to it. THen javascript can process those parameters. Google whether jquery can process query string parameters.

Embed a simple container like jetty then use Jersey or a Simple Servlet

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745423458a4627070.html

相关推荐

  • java - Communication between a desktop app and a web app? - Stack Overflow

    I'm interested in having a desktop application send messages to a web app. Specifically, the deskt

    12小时前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信