This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Here's why I ask: PubSubHubbub (or PuSH) is a fairly new take on making RSS/Atom syndication more real-time. The problem is, there aren't a lot of Atom/RSS readers that support receiving updates via push.
The easiest/simpler (smarter?) thing to do would be to have a server receive the pushes, then a JavaFX client that just makes ajax-y calls to the server and updates as items come in. But is there any way to make a JavaFX app/applet (still not familiar with the terminology of JavaFX) a "server" by embedding something like Jetty? The other major pitfall is NATing, but again, don't know enough JavaFX to know if that is even possible.
Maybe a better question is - what's the best way to communicate between a JavaFX app and a server? HTTP calls from JavaFX to server only? Or is there any sort of "receive" mechanism that can be used in JavaFX?
On the simple, firewall-safe side of things, JavaFX comes with an HttpRequest mechanism that could be used together with a server that supports HTTP server push in order to do notification from server to client.
On the complicated, but very powerful side of things, you could do a full HTTP server like you suggested. JavaFX applications can take full advantage of any existing Java libraries (even a full http server like Jetty), so it is conceivable you could spawn a whole client-side server for bi-directional messaging. At least two caveats with going down a path like this are that you may run into firewall issues on the client, and will need to have a signed application to get permission to start a ServerSocket.
You're absolutely right - firewalls and other issues would be a bit of a nightmare (if not showstopper), but I may have a workaround (private closed networks can be useful at times). Really just need to sit down and look at the JavaFX and Java library integration - does Pro JavaFX cover any of that? Some of the other JavaFX books seem to be mostly focused on JavaFX (and rightly slow), but not necessarily how it interacts with Java.
Joined: Aug 30, 2009
Weiqi has a whole section in Chapter 4 dedicated to Java and JavaFX interoperability, which you will definitely find useful. It is really pretty transparent to call Java and use Java data types, including arrays and lists. Also, by using Java interfaces you can have your JavaFX and Java classes extend the same class hierarchy, making the integration even more seamless.