[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

webrick refresh on event

Roeland Moors

12/27/2004 10:59:00 AM

I'm using webrick to display some logging.
The goal is to display a log item as soon as it happens.
But how can I tell webrick to refresh the page?
I can put some html code to refresh every x seconds, but that's
not really what I want.

When creating a servlet I can respond to GET,POST,... requests,
but I want the server to do the refreshing.

Is this possible?

--
Roeland


1 Answer

Dan Fitzpatrick

12/27/2004 5:45:00 PM

0

I'm new to webrick but I think this will work. You can leave the
connection open and pass Javascript to the browser as events happen. You
basically are sending a page that take 10 or 20 minutes to create. After
10 or 20 or 30 minutes or whatever, you can refresh the entire page and
start the loop over.

# output your log framework with the javascript method addLogEvent()
# for each event pass a new javascript block (or simply plain text
appending to the log)
puts '<script type="text/javascript">addLogEvent(...);</script>'

You should add a newline after each Javascript block.

In cgi mode of webrick, you can just print the above javascript blocks
as they happen. Pass a blank event every 30 seconds if the log had no
activity to keep the browser from timing out.

I'm not sure how to do this in servlet mode since it looks like you pass
the complete response to the response handler. But I'm not sure.

Dan


Roeland Moors wrote:

>I'm using webrick to display some logging.
>The goal is to display a log item as soon as it happens.
>But how can I tell webrick to refresh the page?
>I can put some html code to refresh every x seconds, but that's
>not really what I want.
>
>When creating a servlet I can respond to GET,POST,... requests,
>but I want the server to do the refreshing.
>
>Is this possible?
>
>
>