home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 May / PCO_5_97.ISO / FilesBBS / OS2 / OS2WWW42.ARJ / OS2WWW42 / OS2WWW42.ZIP / SYS402.R4 / REXX-BIN / SVRPUSH.CMD < prev    next >
Encoding:
Text File  |  1996-04-29  |  2.6 KB  |  77 lines

  1. /*******************************************************************************
  2. *
  3. * This module presents example PowerWeb Server++ Direct APIs.
  4. *
  5. *    Implements SERVER-PUSH to demonstrate a sequence of documents being
  6. *    sent to the client's browser at one second intervals.
  7. *
  8. * IMPORTANT:
  9. *
  10. *  YOU MUST HAVE A SERVER-PUSH COMPATIBLE BROWSER in order to view
  11. *  this document properly. Netscape Navigator 1.1 or later is OK.
  12. *  IBM's WebExplorer currently (version 1.1) does NOT support it.
  13. *
  14. * COPYRIGHT:
  15. *   CompuSource (Pty) Ltd
  16. *   Licensed Materials - Property of CompuSource (Pty) Ltd
  17. *   (C) Copyright CompuSource (Pty) Ltd 1994, 1995.
  18. *   All Rights Reserved
  19. *   Use, duplication, or disclosure restricted by international
  20. *   copyright law.
  21. *
  22. *******************************************************************************/
  23.  
  24. Parse Arg parcel
  25.  
  26. /* Set up some constants we will be using several times */
  27. boundary    = "YouShouldNeverSeeThis"
  28. crlf        = '0d0a'x
  29. mimeStart= "--"boundary""crlf
  30. mimeEnd    = "--"boundary"--"crlf
  31. content    = 'multipart/x-mixed-replace;boundary="'boundary'"'
  32.  
  33. /* Add in an extra Rexx package for sleeping */
  34. call RxFuncAdd 'SysSleep', 'RexxUtil', 'SysSleep'
  35.  
  36. /* Grab a handle to the server's output variable for quick reference */
  37. html = ServerFind(parcel, "Request:/Result")
  38.  
  39. /* Tell the server we are not sending normal HTML output */
  40. call ServerWriteText parcel, "Request:/Header/Out/Content-type", content
  41.  
  42. /* Tell the server to send data immediately to the client's browser */
  43. call ServerWriteText parcel, "Request:/ImmediateWrite", "1"
  44.  
  45. /* Tell the browser we will replace the current page being viewed */
  46. call ServerWriteText html,,"HTTP/1.0 200 OK"crlf
  47. call ServerAppendText html,,'Content-type: 'content''crlf''crlf
  48.  
  49. /* Send the boundary text for the first document */
  50. call ServerAppendText html,, mimeStart
  51.  
  52. /* Display a series of 10 documents in sequence */
  53. do counter=1 to 10 by 1
  54.  
  55.     /* Compose the document to send - it could equally have been an image instead */
  56.     message    =    "Content-type: text/html"crlf
  57.     message    =    message || crlf
  58.     message    =    message || "<h2>Document number" counter"</h2>"crlf
  59.  
  60.     /* The final document has a special trailer to tell the browser we are finished */
  61.     if counter < 10 then
  62.         message    =    message || mimeStart
  63.     else
  64.         message    =    message || mimeEnd
  65.  
  66.     /* Send the document to the client's browser */
  67.     call ServerAppendText html,,message
  68.  
  69.     /* Wait for a second before sending the next document */
  70.     if counter < 10 then
  71.         call SysSleep 1
  72. end
  73.  
  74. /* Tell the server everything was OK */
  75. return "0"
  76.  
  77.