Hi Wim, Thanks for your info!
Is there a difference in performance in the two mechanisms? I understand the first one, that way I can just create a polling mechansm (which I what I did before in javascript) The 2nd alternative, does this just open a 2nd tcp conn outside the browser to communicate between server and client (and that way allow out of band communication). It avoids the polling. Actually I do not mind the polling while my application is busy, but I am not too eager to do it always. Let me tell a little bit more about my use case. I have a small arm board that will have a web based UI. It will be possible to connect a digital camera to the board and then the board will download the pictures from the camera. In the web based UI I want to tell if the cam is connected or not and if so how far it is downloading the pictures. Preferably without user intervention at the browser side. Anyway, I think I have enough info to make it work with polling and WTimer, and I can always switch to server initiated events later on. Best regards, Frans. 2009/2/18 Wim Dumon <[email protected]>: > 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
