SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : The Server :

Previous DiscussionNext Discussion
 "Real Time" data "push" to a client...

I want to "push" real-time data to a client, using PHP (with AJAX) or maybe a Java Applet.

I thought of just writing a simple AJAX function that uses setTimeout() to poll the server every few seconds, but I figured that if traffic increased beyond X users, that it would really, really bog down the system.

What I'm really wanting to do is something similar to the game tracker systems you see in professional sports.

Can anyone point me in the right direction? I've never done an app of this type before, and I think I can do it with a nudge in the right direction. Google really hasn't turned up much for me yet.

Basically, I want it to work like this:

A person is assigned to log plays. That person logs a play to the server, which then "pushes" the data to the client, in "real time".

I found an article that says it could be done in Silverlight, but right now I want to focus on a PHP/AJAX or Java Applet solution, as the people I would be doing this for are using a PHP hosting company. Unless Silverlight can run on Linux...

Started By Monte on Aug 31, 2009 at 7:06:04 AM

7 Response(s) | Reply

Earlier Replies | Replies 1 to 7 of 7 | Later Replies
Goto Page: 1
Terry Young on Aug 31, 2009 at 6:29:36 PM (# 1)
This message has been edited.

It seems that Flex + Flash Communication Server might also be an option, though I have no experience on it.

http://www.adobe.com/devnet/flex/articles/datapush.html

There's a sample there to play with.


Jockrock on Sep 8, 2009 at 3:13:40 AM (# 2)

Flash would certainly do it and it is definately the choice of the sports sites who deliver the LIVE scorelines etc. See skysports.co.uk for a good example. A looping newsfeed script simply makes the http request on every loop thus changing to the current info.

This can also be doen with a simple newsfeed ticker system if you incorporate the httpRequest with a (say) SQL statement or query. Good quality CSS can make AJAX look and feel like Flash.

I haven't done either but have done database lookups from within Flash ActionScript and have used AJAX enough to know it's do-able.

So sorry, no samples , but yes, I think your thinking is along the right tracks.

Would be good to see the solution.


Monte on Sep 8, 2009 at 7:59:02 AM (# 3)

Well, I played with it for a bit over the weekend, and it looks like CSS/AJAX will be my approach.

What I essentially did was to create a PHP file that accepts a query string, and sends me back what I need (the # of records).

So basically, it looks like this:

mypage.php?q=1

And that page is called through AJAX, which essentially populates a DIV on a page.

The truncated pseudocode looks kind of like this:

setTimeout(myFunction, 1000); // do it once per second.

// set up a for-loop since the db is already populated, to "simulate" added records. Only doing 20 records.

for(x = 0; x < 20; x++){
// pass x to the query string.
..."mypage.php?q=" + x;
// populate div...
document.getElementById('myDiv').innerHTML = result;
}

You get the idea.

I would, of course, have to modify the code to access the database as data is being entered (essentially remove the for loop above, as the records will increase as information is added).

The only real concern I have is hitting the server once per second. I guess I could do it every 5 seconds, though.


Terry Young on Sep 8, 2009 at 7:23:35 PM (# 4)

push, pull, poll... all have their own pros and cons.

I real push is actually invoked from the server. Where as in your case, being triggered from a setTimeout is still actually a pull (or what some people call polling)

Which ever approach you choose, there comes a moment where you'd have a bottleneck somewhere, which needs optimization.


Make sure your "myFunction" checks the status of the last request (as you are doing it once per second, that's a lot of traffic)

And I would add something on the back-end as well, such as a "last updated time" field.

e.g. If my last pull was on 3:00:00 PM, the next visit to the server would be 3:00:01 PM, and instead of a heavy query, simply query the last updated time, if it's, say 2:50:00 PM, then there's no point to send anything back to the client, because there's nothing to update.

My point is, there's lots of areas where you have to optimize.


hotpotatoes on Jul 6, 2010 at 5:12:56 AM (# 5)

how do you make servers:-{}


hotpotatoes on Jul 6, 2010 at 5:13:39 AM (# 6)

make me a client plz>>>>>><<<<<<<


hotpotatoes on Jul 6, 2010 at 5:14:29 AM (# 7)

HFUIHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH

YHHHHHHHHHHHHHHHHHHH

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

H

 


Earlier Replies | Replies 1 to 7 of 7 | Later Replies
Goto Page: 1

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.