2 Replies Latest reply on Jun 13, 2006 7:03 PM by jonnybennett

    messages

    jonnybennett Level 1
      Hello. I am creating a messaging system for my site. However I would like it so that if you are online and you receive a new message, for a m.c. to popup and inform you that you have a new message.

      However how would I go about this?

      My messages are all stored in a mysql database. Therefore..

      Would I….

      1/ when a user logs in, I can create a m.c. to popup to inform the user of any new messages…easy. Would I then on login store the number of new messages in a variable, and then using setInterval run a function every 2 mintues, that willrun a php script that will check the database to see if the number of new messages has increased. If new messages increases, then the m.c. will popup with ‘you have received a new message’.

      Although to run a setInterval to query my database every couple of minutes do you think this is very intensive on memory?

      Alternatively would I just do everything in php and then when there is a change inform flash???

      Is there a better way to do this?
        • 1. Re: messages
          Webmaster_Pete Level 1
          Jonny,
          Your idea on using setInterval is good way of doing it. 2 minutes seems like a reasonable timeframe, I'd even say 1 minute would be ok. The biggest concern usually with doing something like this is how many users will be sending requests to the server, how big the data is being sent back and forth and what system type is this being served from. If this is for a small group of people running this off of a home computer it's ok but if it's open to the internet to join then I'd go with a hosting plan.

          - pete
          • 2. Re: messages
            jonnybennett Level 1
            thanks for the response... but what do you mean by a hosting plan? do you mean a server with a messaging system? I was hoping for it to be for a large amount of users (open on the internet)... The problem is that say I had 1000 people all logged in that would mean that all 1000 would be sending a request to find out if the number of new messages had increased. However the amount of data is fairly small, therefore I guess if I have a server that could handle 1000 users, then for each of those users to run a script every 2 mins wouldn't make a lot of difference. Anyone know of a better way... or is it going to be the same kind of problems?