Skip to main content
gamedev.net
🔒 Locked

[web] CGI Wait Screen?

Started by 31337 14 replies 2.4k views
Original Post
31337
31337
I wrote a CGI web service in C++ and I want to add in some sort of intermediate waiting page. How do I do this? I'm sort of stuck, this is an esoteric topic. Thanks in advance.
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
C-Junkie
C-Junkie
explain slightly more about whaqt you want to do.
C-Junkie
C-Junkie
i'm sure he knows about refresh, and since its an cgi page, he can just send an http one, rather than a meta one.

The devil is in the details, do you want to wait a few seconds? or wait until some complicated transaction completes?
31337
31337
I was thinking of something where they click submit and then a new page pops up that says their request is being processed. It could take anywhere from 20 seconds to a day and so I think I might put in time estimates, but that would be preferable. What is a meta refresh? Thanks
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
igni ferroque
igni ferroque
Will the application finish writing the output before the submitted data has been processed? If so, output the intermediate page and set a refresh for 5-10 seconds (or however long you need) and keep outputting that page until the script detects that the submitted data has been processed. Otherwise, use DHTML/javascript to display the wait message and disable the form.
Free Mac Mini (I know, I'm a tool)
31337
31337
Currently my program doesn't output anything until after the data has been processed. How does refreshing work? How does that interface with my C++ program? Thanks
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
pjcast
pjcast
Check out here for a little info on either the http refresh or meta refresh: scroll down to client pull
http://wp.netscape.com/assist/net_sites/pushpull.html

You can also google for more info.

As far as how it integrates into you c++ cgi program, no differently then how you send any http headers or html text. You send it down the stream.
31337
31337
Alright, this is enough to make me bash my head through a wall. I read that document (and many others) and I can't figure out why my program doesn't work. The problem is that instead of processing the data as multipart/mixed it is outputting at the top of my data:

--PageBorder
Content-Type: text/html

At the start I output:

Content-type: multipart/x-mixed-replace;boundary=PageBorder\n\n

Then:

--pageBorder\nContent-Type: text/html\n\n

Followed by my HTML data and ended by:

\n--PageBorder--\n

Now what on earth is wrong? Why is it sticking my pageborder into the output page? I am really stuck and getting frustrated. Thank you.
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
Kylotan
Kylotan
I've never seen that sort of thing used by HTTP before. I don't think it's a good idea to rely on it. Client pull is probably the way to go.
31337
31337
Client pull wouldn't work for me because I don't know how long it will take for my document to be ready.
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
pjcast
pjcast
Do this then, have your cgi write an entry to a file or database with the a user_id session with a flag of some sort that it is working and set a complete flag when done... Send the clients browser with a refresh rate of (depending on your average completion time) 5-10 (or more) seconds. But, also put a hidden form on the page with some kindof flag (such as task=check_status) or just have it go to status_check.cgi or whatever.

When the page gets refreshed, it will initiate a new cgi process app on your server, but the first thing this app does is check the flag in the database or file to see if the process is done, if not, resend refresh and try again. If it is do whatever else you were trying to do.

Sounds reasonable to me.

fractoid
fractoid
In the past, I've always just had a page that displays the 'loading...' message, and then immediately forwarded to the new, takes-ages-to-load page. As long as no actual data is sent by the server until the time-consuming bit is complete, most browsers seem to just wait while displaying the previous page (in this case, your loading page).
pjcast
pjcast
fractoid, I never thought of that, sounds like it would work prety good.

I just thought of another benifit in refreshing though, you could also modify my suggestion and have an entry in the data base for a percentage of work done, an a time count down based on that. This could be updated by the cgi script still working, and then cgi script that gets invoked during refresh would just read the database and update the screen with new info (such as a completion bar graph)
31337
31337
How about I do this:

Create a temporary html output file where I copy a generic waiting message. Forward the user to that temporary html file. That temporary html file refreshes every 15 seconds (or whatever). When my process is done, I open that temporary html file and replace it with my output data and then close the file.

Only one question, what if I open the file right when the client is trying to refresh? What would happen? Is it safe?
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/
31337
31337
Alright so I made it so that my program does the following:

Reads the waiting screen html file and copies it to a temporary HTML file.

It then forwards the user to the temporary HTML file.

The temporary HTML files meta-refresh with CONTENT set to 10.

At the end of the program execution, it overwrites the wait screen with the output.

The problem I'm having is that when I send Location:waiting.html\n\n, the browser keeps pausing until the entire program is complete. How do I tell it to close the connection and go to the waiting screen?

Thanks
OpenGL Revolutions http://students.hightechhigh.org/~jjensen/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.