Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 108,965 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,387 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Delete if

 
Reply to this topicStart new topic

Delete if

JBrace1990
post 2 Jul, 2008 - 02:49 PM
Post #1


D.I.C Regular

Group Icon
Joined: 9 Mar, 2008
Posts: 422



Thanked 19 times

Dream Kudos: 350
My Contributions


right now, i'm setting up an alert system for a Flex Chat i'm developing... it uses PHP as a backend to output XML data...

now, i figured out (i think) how to make the alert appear, but i'm having a bit of a writers block...

see, when everyone online at the time the alert is sent gets it (less then 2 seconds total), I want the entry deleted... but at the same time, I need to make sure EVERYONE saw it... so i'm not sure how to do it...

for example, an alert is added when 5 people are online... I want to make sure all 5 people see it (even if there is lag)... now it has a 1 second update (think chat, you want it in somewhat real time), though I can make an additional update that goes like every 5 seconds...

i'm just having trouble thinking of this... can anyone offer a new perspective?
User is offlineProfile CardPM

Go to the top of the page


joeyadms
post 2 Jul, 2008 - 06:36 PM
Post #2


D.I.C Head

Group Icon
Joined: 4 May, 2008
Posts: 145



Thanked 6 times

Dream Kudos: 600
My Contributions


I havent worked with chats really, but I thought I'd throw my thoughts in, maybe it will spark something in your mind?

the illusion of realtime is done by asynchronous requests every 1 second. What you could do is just have a javascript function to evaluate alert times or something.

So that if the timestamp of an alert is 3 seconds or so old then to not show it.

You could, in theory, make a more robust platform where the last request timestamp is stored in a javascript var, and if the returned alert timestamp is in between requests, then you can display it for x seconds.

Or you could store alert Id's in an array or such, and only display alerts not in that array.

Like I said i'm far from pro at chat apps, but its something to get you thinking.
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 2 Jul, 2008 - 07:32 PM
Post #3


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,206



Thanked 38 times

Dream Kudos: 725
My Contributions


If you wanted to make sure that everyone saw it ou could set up a separate php file with a separate xml request going to it, and then have it popup a box saying the alert message when there is one. Then when the user clicks the ok/cancel button (or whatever) it sends an item to the database that basically says the user has seen the alert. Thatway you can set it to only look for alerts that haven't been seen by the user, and update in real time. Though this will probably eat up more CPU and everything as it would be having 2 queries to the server per second.
User is offlineProfile CardPM

Go to the top of the page

JBrace1990
post 2 Jul, 2008 - 09:19 PM
Post #4


D.I.C Regular

Group Icon
Joined: 9 Mar, 2008
Posts: 422



Thanked 19 times

Dream Kudos: 350
My Contributions


2 is nothing compared to this >.>;; try like 12 per second yinyang.gif

anyway, before you posted it Betawar, I actually went ahead and did that lol... i added an alert.php that checks for the latest alert, and checks the status of the users "readAlert" field... if it's no, it displays the alert, else it displays nothing.... actually, the XML outputs <poster>fake</poster><content>fake</content>, but I have the flex App ignore it =p
User is offlineProfile CardPM

Go to the top of the page

BetaWar
post 2 Jul, 2008 - 09:38 PM
Post #5


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,206



Thanked 38 times

Dream Kudos: 725
My Contributions


Wow, okay I guess that explains some of the browser slowness smile.gif
User is offlineProfile CardPM

Go to the top of the page

JBrace1990
post 3 Jul, 2008 - 07:19 AM
Post #6


D.I.C Regular

Group Icon
Joined: 9 Mar, 2008
Posts: 422



Thanked 19 times

Dream Kudos: 350
My Contributions


yeah.... i don't really know how to speed it up, but i'm gonna try to cut down on the amount of queries...
User is offlineProfile CardPM

Go to the top of the page

JBrace1990
post 3 Jul, 2008 - 08:51 AM
Post #7


D.I.C Regular

Group Icon
Joined: 9 Mar, 2008
Posts: 422



Thanked 19 times

Dream Kudos: 350
My Contributions


ok, next question.... when someone enters the chat (logs in), a message is added to the database that says "$x Has entered".... I need a way to add "$x has left"... i'm thinking of maybe doing a javascript call to a php function? but idk...

I could get it to work if I added a logout button, but then people who just close the window (like me), won't be marked as having left...

any ideas?
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/4/08 10:09PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month