The online racing simulator
Is it possable to...
1
(32 posts, started )
Is it possable to...
...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? Remember, live without F5.

Thx, T-RonX
Yes, LFS Spectator into a web page. But I need to know the best way to it.
#3 - ikkah
Yes! How did he do that? I'll get in contact with him.
It would be possible in flash using the sharedObjects or the flash communication server i think.... i will look into it
Quote from nikimere :It would be possible in flash using the sharedObjects or the flash communication server i think.... i will look into it

Ok, thanks
i've never looked into inSim and dont know much about it.
What way is the data supplied to you from LFS?
whats the username and pw?
Quote from nikimere :whats the username and pw?

:doh:
Attached images
lfswiki.jpg
Quote from T-RonX :Yes! How did he do that?

Java. Urgh.

This sort of thing could be done via a backend script and some AJAX'y loveliness.
Quote from AndroidXP ::doh:

smart arse!!
Attached images
login.jpg
Ahahahah

Not my fault that you have such a sh.. what browser is that?
Quote from ikkah :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 ... morelosmas_escuderias.htm

Please let me know your thoughts.
best regards
Nelson
Quote from the_angry_angel :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.
Quote from Dygear :It MUST be Open Source

Which 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.
GPL? That good for you?
Dojo Toolkit for the AJAX part, unless you want to build from the ground up...
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.
Quote from Anarchi-H :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
Who said anything about a database? Its going to work like this.


<?php 
$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.
Quote from Dygear :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 displayed
and 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.
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.
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.
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.
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 .
1

Is it possable to...
(32 posts, started )
FGED GREDG RDFGDR GSFDG