PDA

View Full Version : Is it possable to...


T-RonX
23rd January 2006, 13:11
...to put live racedata from lfs, like car positions, on a website. Without refreshing, just live animated. I was thinking about a java applet or something.
I already got the car positions via InSim, any idea how to put the data on a website? :scratchch Remember, live without F5.

Thx, T-RonX

T-RonX
23rd January 2006, 14:40
Yes, LFS Spectator into a web page. :) But I need to know the best way to it. :shrug:

ikkah
23rd January 2006, 15:23
http://live.lfs-suomi.com/s2live.php

Something like that?

T-RonX
23rd January 2006, 15:31
Yes! How did he do that? :) I'll get in contact with him.

nikimere
23rd January 2006, 15:33
It would be possible in flash using the sharedObjects or the flash communication server i think.... i will look into it :)

T-RonX
23rd January 2006, 15:35
It would be possible in flash using the sharedObjects or the flash communication server i think.... i will look into it :)

Ok, thanks :thumb:

nikimere
23rd January 2006, 15:38
i've never looked into inSim and dont know much about it.
What way is the data supplied to you from LFS?

T-RonX
23rd January 2006, 17:50
LFS sends UDP packets (http://www.lfswiki.net/index.php/LFS_S2_Manual:InSim) to an external program.

nikimere
23rd January 2006, 18:14
whats the username and pw?

AndroidXP
23rd January 2006, 18:33
whats the username and pw?
:doh:

the_angry_angel
23rd January 2006, 18:46
Yes! How did he do that?Java. Urgh.

This sort of thing could be done via a backend script and some AJAX'y loveliness.

nikimere
23rd January 2006, 19:14
:doh:
smart arse!! :razz:

AndroidXP
23rd January 2006, 19:16
Ahahahah :rofl:

Not my fault that you have such a sh.. what browser is that? :p

NelsonGPV
3rd March 2006, 14:45
http://live.lfs-suomi.com/s2live.php

Something like that?

I would like to ask you if you are intrested on sharing your application with LFS Mexico.

We have a championship going on with sponsors and I would like to implement this application so my sponsors would be able to follow the race of their car. with out having LFS.

Please follow the links to see the details of the championship. (spanish only sorry)
this are the sponsors cars.
http://www.granprixvirtual.com/Campeonato/campeonato_morelosmas_escuderias.htm

Please let me know your thoughts.
best regards
Nelson

Dygear
3rd March 2006, 16:08
Java. Urgh.

This sort of thing could be done via a backend script and some AJAX'y loveliness.

I've got the time, how about you? Want to get together on this? I would love to do it in AJAX with PHP. Just one thing. It MUST be Open Source. Sign up at http://www.thenz.org/eagle/ and I'll give you some access so we can start work.

PHP Functions :
get_driver_username(id); // Screen Name on The Server.
get_driver_speed(id); // In Meters Per Second.
get_driver_name(id); // LFS Username.
get_driver_split(id); // Time In Milliseconds.
get_driver_pos(id); // X, Y, Z, DegX, DegY, DegZ.
get_driver_car(id); // Car (From The String) // Ie FO8.
get_driver_lap(id); // Int with lap number, such as 8.

get_server_layout(); // Returns array with ITEM => X, Y, Z, DegX, DegY, DegZ.
get_server_racers(); // Array with Driver => Id;
get_server_track(); // 011 ( I think its BL GP ).
get_server_wind(); // 12 (In MPH) // If Possable.
get_server_laps(); // Int with total laps.

That can be used inside PHP to get all of the information needed. I really don't think there is any more functions needed.

the_angry_angel
3rd March 2006, 17:24
It MUST be Open SourceWhich license?

In theory I have no problem contributing. The problem is fitting it in with all my other current projects :( I'll sign up Saturday evening when I'm at home next and have a moment to look over things.

Dygear
3rd March 2006, 18:16
GPL? That good for you?
Dojo Toolkit (http://dojotoolkit.org/) for the AJAX part, unless you want to build from the ground up...

Anarchi-H
3rd March 2006, 22:43
Hmmmm... hate to be the voice of doom and gloom but I'm not so convinced PHP & AJAX is going to pull this off.

What will you use as the insim listening daemon? You can send data on-demand thanks to UDP, but you still need to listen for it on a socket, in a loop. Unless you have some special raport with your hosting provider, an indefinitely running script isn't going to please them. If you have a VPS / dedicated server to act as listener then you could use a rather convoluted PHP script, or use a process to listen (i.e, java, .net or c) though.

Secondly, how live will it be? Updates every 1 second? 2 seconds? 5seconds? AJAX applications usually aren't this lively and to be so is an amazingly inefficient way of going about a dynamic interface. 5 seconds isn't really enough time for a decent overview, and on some slower connections or during peak times, 1 - 2 seconds may not be enough time for the client to recieve and process the async data before the next set of data arrives, thus resulting in an inconsistent behaviour.

In addtion, the added server load will most certainly be unwelcome if you are on shared hosting and get even a few concurrent viewers to the "live" page, not really because of bandwidth, but more because concurrent server hits coupled with PHP being invoked every hit is going to cause a performace drain.

On top of that, what will be your interim data format, between listening server and AJAX request scripts? If you were thinking about a database, you should probably think again because the data will be just coming & going too quick to be effective & the query overhead will be huge when you add it up. Flat file could work, but that means you have to contend with locking, filesystem overheads & all the other niceties of concurrent file access with such rapid updates of data.

Over all, neither PHP or AJAX are the right tools for this job, but please feel free to prove me wrong.

NelsonGPV
4th March 2006, 05:09
Hmmmm... hate to be the voice of doom and gloom but I'm not so convinced PHP & AJAX is going to pull this off.

What will you use as the insim listening daemon? You can send data on-demand thanks to UDP, but you still need to listen for it on a socket, in a loop. Unless you have some special raport with your hosting provider, an indefinitely running script isn't going to please them. If you have a VPS / dedicated server to act as listener then you could use a rather convoluted PHP script, or use a process to listen (i.e, java, .net or c) though.

Secondly, how live will it be? Updates every 1 second? 2 seconds? 5seconds? AJAX applications usually aren't this lively and to be so is an amazingly inefficient way of going about a dynamic interface. 5 seconds isn't really enough time for a decent overview, and on some slower connections or during peak times, 1 - 2 seconds may not be enough time for the client to recieve and process the async data before the next set of data arrives, thus resulting in an inconsistent behaviour.

In addtion, the added server load will most certainly be unwelcome if you are on shared hosting and get even a few concurrent viewers to the "live" page, not really because of bandwidth, but more because concurrent server hits coupled with PHP being invoked every hit is going to cause a performace drain.

On top of that, what will be your interim data format, between listening server and AJAX request scripts? If you were thinking about a database, you should probably think again because the data will be just coming & going too quick to be effective & the query overhead will be huge when you add it up. Flat file could work, but that means you have to contend with locking, filesystem overheads & all the other niceties of concurrent file access with such rapid updates of data.

Over all, neither PHP or AJAX are the right tools for this job, but please feel free to prove me wrong.

I read the post and I am confused, can anyone tell me if this could be possible ina short time period. Sponsors in our league want to see thir cars during race at least to have the live timeng similar to the one F1 uses in thier offical home page and is mada with java. please some one could help:scratchch

Dygear
4th March 2006, 05:09
Who said anything about a database? Its going to work like this.

$this->track = get_server_track();
$this->laps = get_server_laps();
$this->driver = get_server_racers();

for( $i = 0; $i < count($driver); $i++ )
{
$this->car[$i] = get_driver_car($i);
$this->pos[$i] = get_driver_pos($i);
$this->spe[$i] = get_driver_speed($i);
}

The class will do all of the rendering work. Set the update time to 1/6, 1/3, 1/2, 2/3, 5/6, or 1 time a second and the for loop will execute and render out as needed.

Anarchi-H
4th March 2006, 09:51
The class will do all of the rendering work. Set the update time to 1/6, 1/3, 1/2, 2/3, 5/6, or 1 time a second and the for loop will execute and render out as needed.

I think you need to do a bit more research in to both AJAX and PHP here because what you've said there is simply not possible.

An AJAXified request goes something like...

Client sends initial HTTP request for page
Webserver acknowledges with a 200 and sends back data required
JS is loaded by client browser (JS was sent by the server)
JS AJAX framework initialised, requests any intial data from the server by HTTP
As the user interacts / a timer triggers events, the JS framework makes additional HTTP requests from the server.PHP comes in to when the HTTP requests are made from the server. For example, a ficticious mailbox request might go like

User clicks "Trash"
AJAX framework requests "gettrash.php"
Webserver starts up PHP, processes gettrash.php & returns the result to the requesting client (the AJAX framework) in the form of an HTTP response.
AJAX framework converts this in to renderable output & it is displayed
User then searchs for "moo"
AJAX framework requests "search.php?q=moo"
Webserver starts up PHP, processes search.php & returns the result to the requesting client (the AJAX framework) in the form of an HTTP response.
AJAX framework converts this in to renderable output & it is displayedand so on...

As you can see, PHP is invoked "on demand", and not in one big ass loop like you envision. As such, PHP has finished processing and is no longer able to do anything by the time any rendering has to be done.

Also, you seem to be misunderstanding the way you are going to be able to interact with insim. Each PHP request is delt with in a separate thread / process, depending on how it is setup. Either way, PHP can't communicate between scripts without an interim data format (one script stores it so another can access it, like a cache or database).

And finally, a server CANNOT push data through HTTP. It has to be pulled. What I mean by this is that a client must first request the data from the webserver before the client can recieve it. As such, it will be JS & the AJAX framework setting the update interval, and not PHP.

Dygear
5th March 2006, 00:58
The page will be updated from the client side via a java script function. That function will request the page with the PHP code on it. Take alook at the dojo engine. It's quite good.

the_angry_angel
5th March 2006, 11:25
Presumably you're considering connecting to InSim (via PHP, on the server) per XMLHTTPRequest, and querying the game server, then disconnecting Dygear? Doing this is a bit of a problem, as it creates a massive overhead and will be too laggy. We could get around this by doing some clever predictive stuff - but it wouldnt be very accurate.

Something else to consider would be using a daemon/service, either as cgi php or as another language, running to have a constant connection with InSim and then accepting queries via its own extra listening socket. Or, as Anarchi says, having the daemon input it all into a database which we then query.

Anarchi-H
5th March 2006, 12:26
If you think you can do it, by all means give it a go. If I can help I will, but as I've said before, I don't think that this a practical application of AJAX.

Here is a summary of the pitfalls I see. I think that if you can overcome these with suitable solutions that will work together, you should be able to pull it off.


How will you interact with InSim?
If applicable, how will you store the data between the insim client recieving it, and the AJAX enabled page requesting it?
How often will it update? Will the mehods above work well enough with this interval?Those probably aren't all of them, but I think that those are the major ones.

The solutions I see to point 1 is either a convoluted PHP script, an indefinitely running PHP script or, as afore mentioned by myself and TAA, some kind of client that can run indefinitely. If you can do that in a threaded language, and can cope with the complexities of sharing data between threads, you should be able to use this to overcome point 2 by also listening for requests from the AJAX client, thus eliminating the need for a temp storage media.

If the update interval isn't too high, a DB might work, or possibly some kind of complex cache system, but I think with the level of frequency you might want these aren't practical solutions. This, IMO is the biggest issue.

Dygear
5th March 2006, 16:00
You could use a flat file. But reading and writing from/to a file evey 1/6 of a second is a bit excessive. AFAIK my PHP is running in CGI mode :).

the_angry_angel
5th March 2006, 16:16
Ok, lets go back a few steps, to see if we're all on the same page.

How do you see the whole stack working together, in detail?

Dygear
6th March 2006, 20:31
Keyboard dose not work so i am using an on screen one.

Client (Browser makes page request) -> Webhost ( PHP Functions get data form LFS's InSim, PHP then parses the data into html. ) -> Client.

For speed PHP will allready have to be connected to the LFS server InSim program. But this will require PHP to be running all of the time. While most server only allow PHP to run for only 30 seconds my web host runs it for how ever long it is needed. Still this is a pit fall we most over come if we want this to work on all servers.

AJAX can be used for some guess work when it comes to mapping stuff out. Just like LFS itself guess where the car will be in the race while it still has not recived a packet from said client. You could keep open a consent connection with PHP and just call the script itself evey 30 seconds with cron.

Any more ideas?

Keep in mind I am a self taught programmer, so any extra programmer termonlogy will likey go over my head.

Stuff
6th March 2006, 23:56
I might have a solution. Didn't read the whole thread so let me know if there is anything I left out and can include or answer later :)

My solution for NAL anyway, is a manager/webserver! See the screenie to see my test version in action. It connects to InSim as normal (or several InSims in the same window) and each InSim connection has several features: 1) Shows live data in the user list and you can chat. 2) Qualify manager. This keeps a list of everyone that has done a lap in the server and will send lap data via post to a php script or whatever. 3) Status updater. If nothing has been sent to a site after a certain amount of time, this will send server info (host*.txt stuff) to a web script. 4) A webserver! It listens on whatever port for GET or POST requests, can do logins, parses templates, act as a file host, user organization and a banned IP list.

Like I said, this is a test version and is slow going for development. At least while I have classes for another couple weeks. And in a few months after I learn more Java, I will redo the whole program in that. (that one is VB6 :))

Look good? Any requests? UI advice? etc..

Dygear
7th March 2006, 01:02
Ray, your awsome dude. As for the UI, make it look like the F1 Pit wall. Untill then I can give you a F1 style css and image file for you to use.

filur
7th March 2006, 05:23
Keyboard dose not work so i am using an on screen one.

Client (Browser makes page request) -> Webhost ( PHP Functions get data form LFS's InSim, PHP then parses the data into html. ) -> Client.

For speed PHP will allready have to be connected to the LFS server InSim program. But this will require PHP to be running all of the time. While most server only allow PHP to run for only 30 seconds my web host runs it for how ever long it is needed. Still this is a pit fall we most over come if we want this to work on all servers.

AJAX can be used for some guess work when it comes to mapping stuff out. Just like LFS itself guess where the car will be in the race while it still has not recived a packet from said client. You could keep open a consent connection with PHP and just call the script itself evey 30 seconds with cron.

Any more ideas?

Keep in mind I am a self taught programmer, so any extra programmer termonlogy will likey go over my head.

Wouldn't it be a whole lot easier to make an insim client that constantly outputs "renderable" data (to file / sql) for you to grab via ajax / php ?

the_angry_angel
7th March 2006, 09:44
Wouldn't it be a whole lot easier to make an insim client that constantly outputs "renderable" data (to file / sql) for you to grab via ajax / php ?
Yes, which is what we're trying to say.

Dygear, I think you're still missing our point, or we're missing yours. Can you elaborate in a bit more detail on each step in your "plan"?

Dygear
7th March 2006, 22:50
If I bulid it, you will come. I'll make the program, just give me a few weeks.