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
4 Answers
Reset to default 3I 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:
- Put the mon information into a webservice.
- The website sends information, possibly via ajax or by navigating to a different URL or doing a form POST to the webservice.
- 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
评论列表(0条)