I'm building a Drupal module that integrates the "FileCatalyst" Java FTP applet with a standard Drupal form. I'm implementing a hook to submit the form when a file transfer completes. Currently I'm polling the applet with a setTimeout() call, but this method can miss changes of state if they happen too fast.
However, the FileCatalyst object inherits from java.util.Observable – so it's apparently possible to register an observer for the applet and get notifications of state-changes. I'd like to know how to implement this.
Can I use the document.FileCatalyst.addObserver(obj) function from Javascript to get these state-changes sent to a Javascript object? What do I pass to addObserver? How do I construct the observer? What methods does the observer need to implement in order to receive state-change notifications?