How to implement server push operation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vanitha@agilis.st.com.sg

    #1

    How to implement server push operation


    I am developing a Web Interface for a embedded target using CGI-C. I
    have a requirement, which requires a HTML page to be continuously
    updated by the server.ie.,I am dynamically updating the fields of the
    HTML page using Javascript. I generate the javascript code from "C".

    I need to do the above operation as long as the user stays in the
    Current Page. If the user has clicked some other page, i want to stop
    the operation in the server. Is there a way to notify the server
    process when the user clicks some other page.

    I dont want implement this as client pull operation, since i had to do
    some other processing in the server

    Thanks

  • Fred Oz

    #2
    Re: How to implement server push operation

    vanitha@agilis. st.com.sg wrote:[color=blue]
    > I am developing a Web Interface for a embedded target using CGI-C. I
    > have a requirement, which requires a HTML page to be continuously
    > updated by the server.ie.,I am dynamically updating the fields of the
    > HTML page using Javascript. I generate the javascript code from "C".
    >
    > I need to do the above operation as long as the user stays in the
    > Current Page.[/color]

    You can't detect whether the user is 'in the current page', since
    'current page' has no meaning to the server. I guess you you mean
    'whether the user is still displaying the last page that their UA
    requested from this server in one of their currently open windows or
    tabs'.

    All you can tell is whether a script you have installed in a page is
    still polling or not (as you appear to be doing already), you can't
    detect the 'current page' from the server, nor can you detect the URI
    of one page or tab from another (except perhaps in the very limited
    case of child windows opened by one of your pages).
    [color=blue]
    > If the user has clicked some other page, i want to stop
    > the operation in the server. Is there a way to notify the server
    > process when the user clicks some other page.[/color]

    Only if that 'other page' is on your server and the user clicks on
    your page to get there.

    Even if there was some event that on page unload or window/tab close
    would send some undisclosed information to the server, the user can
    kill their browser or stop communication with the server a number of
    ways that prevent the message ever getting through.

    To that extent, your attempt to create a session would be extremely
    unreliable to the point of being useless.
    [color=blue]
    > I dont want implement this as client pull operation, since i had to do
    > some other processing in the server
    >[/color]

    From the HTTP 1.1 specification:

    Abstract

    The Hypertext Transfer Protocol (HTTP) is an application-level
    protocol for distributed, collaborative, hypermedia information
    systems. It is a generic, stateless, protocol which can be used for
    many tasks beyond its use for hypertext,

    ....

    1.4 Overall Operation

    The HTTP protocol is a request/response protocol. A client sends a
    request to the server...

    <URL:ftp://ftp.isi.edu/in-notes/rfc2616.txt>


    In brief, HTTP is stateless, so the client and server only
    communicate when asked to - there is no maintenance of a connection
    or concept of a 'session'. HTTP is based on a client requesting
    information, not the server deciding to sent it.

    You may be able to use a script that is called at regular intervals
    to poll the server and retrieve content at some specified interval,
    but you can't do the reverse, i.e. get the server to poll the client
    to see if it wants more information.

    If your server does not get a request within some multiple of the
    interval, you may presume that the user has 'left the page' and
    terminate their session (as is done by many secure sites like banks
    and stock brokers).



    --
    Fred

    Comment

    Working...