eckhchri / pcars-ds-liveview

Provides a html page for project cars dedicated server and display a map of the current race.
14 stars 1 forks source link

Project CARS and Automobilista 2 liveview

What is it?

The main goal of this project was to show information about races like you need it for TV broadcasts or for race engineers.\ This project is webbased and written in javascript. It polls the Dedicated Server API for Multiplayer sessions of Project CARS 1, 2 and Automobilista 2 to get this information, which is also the main focus. But it can also poll the CREST1/CREST2/CREST2-AMS2 API, which provides the Shared Memory data of Project CARS 1, 2 and Automobilista 2 via HTTP.\ If you open this website it has Google Maps in background, which shows the current race track and markers of all drivers where they are. As overlay you have some tables:

Further there is a recording/playback panel and some other great stuff. You can find more info about the features in the "Nice to know" section at the end.\ It's also important to know that javascript is executed on client side. That means your PC/Tablet/... where you start a browser and open this website is polling the Dedicated Server or CREST API via HTTP requests. Look at the communication schemes for more info.

Screenshot

DEMO Website

Open the website to see a demonstration, click on "Load from URL" and choose a DEMO file.

Usage:

URL paramters

Supports the following Data Sources

Default parameters:

Requirements:

Shared some info in Project CARS Forum

FAQ

Troubleshooting

Javascript is executed on client side. That means your browser is polling the DS HTTP API.\ If you get no data from DS or CREST check your firewall settings on client side outgoing and maybe on DS/CREST side incoming. The tool uses normal HTTP requests, which means your DS can run on another machine. For CREST2 the same, CREST2 must run on the same system where the game runs, but you can open the liveview on another system with a browser. But here the CREST2 TCP port must be open in the firewall of your game system.

liveview polls the following paths on the DS:\ /api/session/status?attributes&members&participants\ /api/list/tracks\ /api/list/vehicles \ We have no authentication implemented, which means these paths must be accessable for public in the DS server.cfg. I think tracks and vehicles are public by default, but session/status not. \ You have to add the following for httpApiAccessLevels in the DS config

httpApiAccessLevels : {
      "api/session/status" : "public"
}

You should be able to open the URL without authentication:\ http://DS_domain_name:Port/api/session/status?attributes&members&participants. If this works, liveview should work,too.

Other relevant settings in DS config:

enableHttpApi : true
httpApiPort : 9000
httpApiInterface : ""

Another problem could be if you open the liveview via HTTPS on your webserver, because the DS is polled via HTTP. In this case your Chrome prevents this and shows an icon on the right side of the address field.\ Then you can click on it and "Load unsafe scripts".

Node Proxy

Liveview is written in javascript and executed on client side. If bigger communities want to use such a tool many clients would query the HTTP API. We don't know how many connections the DS HTTP API webserver can handle and if there could be a negative effect on the DS performance itself.\ For this case we implemented a small Node Proxy which simply queries the HTTP API and provides it again as HTTP webserver.\ Further the Node Proxy is supporting the basic authentication which is default activated in the DS HTTP API server.cfg if you request the path /api/session/status.\ You can find the Node Proxy in the folder "liveview-node".\ Requirements: Linux or Windows with installed Node.js (Download). The basic installation of node.js is enough, because we only use the HTTP module and no other extra modules.

Usage:

Additional Info:\ The Node Proxy can used for the CREST API modes, too. But the normal use case is in my opinion in combination with the DS modes.

Communication Schemes

Screenshot Screenshot Screenshot

Nice to know