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

APIMODE object - CREST/DS Mapping for vars and WebWorker Calls #25

Open eckhchri opened 9 years ago

eckhchri commented 9 years ago

Make such code obsolete: if (APIMODE == "DS"){ aDrivers = Receive_DS_data(DsServerURL, DsPort, 2000, "GETDRIVERDATE"); }else{ aDrivers = Receive_DS_data(CRESTServerURL, CRESTPort, 2000, "GETCRESTDRIVERDATA"); }

better to use:

aDrivers = Receive_DS_data(aAPIMODEMAPPING[APIMODE] [url], aAPIMODEMAPPING[APIMODE] [port] , aAPIMODEMAPPING[APIMODE] [delay], aAPIMODEMAPPING[APIMODE][driverdata]);

use API MODE Object:

aAPIMODEMAPPING = {

    'DS' : {
                    'driverdata' :  GETDRIVERDATE,
                    'tracklist'  :  GETTRACKLIST,
                    'url'        :  'www.eckhchri.de',
                    'port'       :  '80'
                    'delay'      :  2000,
                    'firstdelay' :  100,
                    'svgduration' 600

            },

    'CREST'
            {
                    'driverdate' :  GETCRESTDRIVERDATA,
                    'tracklist'  :  GETTRACKLIST,
                    'url'        :  'localhost',
                    'port'       :  '8080'
                    'delay'      :  100,
                    'firstdelay' :  10
                    'svgduration'  200
            }

    }