Sending data to users browser by server push

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bnashenas1984
    Contributor
    • Sep 2007
    • 257

    Sending data to users browser by server push

    Hi everyone
    I know this post does not belong in PHP forum but I really didn't know where to post it.

    I'v made a PHP shopping cart for some markets that allows the owner to log in to admin area and wait for customers to order.

    Orders should be shown in the admin page as soon as the customers make them.

    Right now i'm sending request to server every 5 second by Action Script 3 (Flash) to check the database to see if there are new orders on the database.

    BUT the problem is that this website could not be used for more than 10 owners at a time because it would be several requests sent to server each second. I'll need a really fast server to take requests for hundreds of market owners..


    So, The question is if it's possible to send the data automatically to the users browser when a new order is made instead of checking the server every second?

    I'v heard about something called Server Push that sends data from server to users browser but I don't know how it works.

    Can anyone help me with this?

    Any help will be appreciated.

    Thanks / Behzad
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    So, The question is if it's possible to send the data automatically to the users browser when a new order is made instead of checking the server every second?
    It is, yes, but it's not "simple". The web (as it is) was not built for stuff like this, so it requires a bit of hacking. See http://ajaxpatterns.org/HTTP_Streaming.

    In HTML5, we will also be able to use Web Sockets, which will allow us to do this sort of stuff much more easily. We will be able to use simple JavaScript to open up a real-time connection to a server and exchange data.

    Today you will need a client applet to do this. Both Java and Flash should be able to do that.

    Comment

    • bnashenas1984
      Contributor
      • Sep 2007
      • 257

      #3
      Thanks Atli
      I appreciate your help.
      I'v been programming with PHP and AS3 for a while but i'v never been close to learning JAVA.

      So it was a bit hard for me to understand the structure of the JAVA applet.

      Do you know if it's possible to do the same thing with AS3 (Flash)?

      Thanks again

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        It seems so, yes:


        That's just a basic socket class, so you should be able to make any kind of request on the server. The example on that site seems to do exactly what you are trying to do though.

        But I am not a Flash (or ActionScript) expert in any way, so I can't really tell you whether or not that works. If you need more help with AS3 you would be better of starting a new thread in the Flash forums.

        Comment

        Working...