Hello Frans, There are two mechanisms for this in Wt: 1. Use a WTimer. The timer runs in JavaScript and the event fires when the timeout is reached. From that event handler, update the status text. This will result in the behaviour you describe. 2. Use server push. This is a more complicated approach. Start with calling WApplication::enableUpdates() to let Wt know that you want to use server initiated events. Then, in order to modify the widget tree outside the session's event loop: - Grab the updateLock (WApplication::getUpdateLock()) - Modify the widget tree (e.g. status text) to reflect the progress - Call WApplication::triggerUpdate() while the lock is still held - Release the lock Server push is demonstrated in the simplechat example.
I recommend to use WTimer if you can, and server push if you must. Read the remarks in the manual of WApplication::enableUpdates() regarding when it is appropriate to use server push. Best regards, Wim. 2009/2/18 Frans Meulenbroeks <[email protected]>: > Hi, > > I understood from the fosdem presentation that there is also a > mechanism to handle server side events, but it is not clear from the > doc or wiki how I should do so. > > My problem is that I have an activity on the server that takes some > time, and I want to show in the browser whether the activity is > running or not, and if it is running how far it is. Starting the > activity is not triggered by the browser but independently by the > server. > > In the past I resolved this by running a snippet of javascript which > would pull a status file from the server through ajax every second. > > Guess this is covered somewhere, but I could not find it; so I would > appreciate a pointer (or a code snippet). Guess it will require a form > of polling. > > Thanks in advance for any suggestion! > > Frans. > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > witty-interest mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/witty-interest > ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
