public class Post extends SIMPluginCallback
Note: It's important to not publish any data that the SIM Vendor would consider cheating, or that a driver would not want shared.
Each user would have to enter the web server address into their settings file for this plugin to start publishing. Each entry will have to have the League ID appended. The League ID can be found by looking at the URL on the Leagues Page to "View" the league in iRacing. PRL's league id for the AdvoCare league is 1643. (NOTE: Using a league id of zero(0) will publish all other iRacing Sessions). Unless a URL is defined for a league, it will not publish anything.
settings.txt: 1. DataPublisher-Post = true 2. DataPublisher-Post-URL-1643 = http://www.YourLeaguesWebsite.com/Data 3. DataPublisher-Post-Interval-1643 = 5000 4. DataPublisher-Post-Log = falseThe plugin will start sending data, for the defined interval in milliseconds, using a HTTP POST with the data as a JSON formatted payload. The web server would have to be able to parse this and store it in a database.
Here's a PHP example. $json = file_get_contents('php://input'); $obj = json_decode($json);The web server doesn't have to use all the fields, but should also expect new fields to be added at any time. Also, each publisher may not be on the same SRA version, thus each driver may be publishing different fields. Also, timing of each driver could be different, such that, 2 drivers could be the leader in position 1, but that should work itself out within a few seconds.
Example JSON Payload (Each of these corresponds to the API call to get them http://simracingapps.com/docs/JavaScriptDoc/index.html):
{ "Version": "1.1 Build: 2016.09.15", "SIMName": "iRacing", "SIMVersion": "iRacing Plugin Version: 1.1 Build: 2016.09.15", "Session/DiffCars/ME/LEADER": -3.211, "Session/Id": "116/1075/45011263/10718048", "Session/IsCautionFlag": false, "Session/LeagueId": 1643, "Session/Type", "RACE", "Session/Lap": 2, "Session/Laps": 200, "Session/LapsToGo": 198, "Session/StrengthOfField": 2443, "Session/Cars": 32, "Session/StartDateGMT": "2016-12-25 01:10:00", "Session/PostDateGMT": "2016-12-25 01:10:05", "Track/Description": "Atlanta Motor Speedway", "Car/ME/TeamName": "Trucks", "Car/ME/DriverName": "James Krahula", "Car/ME/DriverNameShort": "J. Krahula", "Car/ME/DriverInitials": "JK", "Car/ME/Id": 12345, "Car/ME/DriverClubName": "Georgia", "Car/ME/Discontinuality": 0, "Car/ME/ClassName": "GT3", "Car/ME/ClassColor": "14540253", "Car/ME/Description": "Chevrolet Silverado", "Car/ME/DriverRating": "12345-A3.65", "Car/ME/Number": "24", "Car/ME/NumberSlant": "forward", "Car/ME/Color": "14540253", "Car/ME/ColorNumberBackground": "14540253", "Car/ME/ColorNumberOutline": "14540253", "Car/ME/ColorNumber": "14540253", "Car/ME/Lap": 22, "Car/ME/Lap/LED": 1, "Car/ME/PitTime": 13.3, "Car/ME/Gauge/TirePressureLF/Count": 1, "Car/ME/Gauge/TirePressureLR/Count": 1, "Car/ME/Gauge/TirePressureRF/Count": 2, "Car/ME/Gauge/TirePressureRR/Count": 2, "Car/ME/Position": 3, "Car/ME/PositionQualifying": 2, "Car/ME/PositionClass": 1, "Car/ME/PositionQualifyingClass": 1, "Car/ME/Lap/BEST": 32.123, "Car/ME/LapTime/BEST": 3, "Car/ME/LapTime/LAST": 33.222, "Car/ME/Lap/COMPLETED": 21, "Car/ME/Lap/PITTED": 17, "Car/ME/LapTimes": [32.123,32.3,32.4,...], "Car/ME/PitTimes": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13.3], "Car/ME/IsBlackFlag": false, "Drivers" : [ { "Number": "24", "DriverName": "James Krahula", "ClassName": "Trucks" }, { "Number": "61", "DriverName": "Jeffrey Gilliam", "ClassName": "Trucks" } ] }The web server should return the following in the response packet payload. I will see if I can either display these or actually enforce them. The positions are your real-time points positions based on how your league works. I will write new Widget to display these like the Standings App does.
{ "MaxTires": 3, "DriverInfo" : [ { "Car/ME/Number": "24", "Car/ME/TirePressureRF/Count": 0, "Car/ME/TirePressureRR/Count": 0, "Car/ME/TirePressureLF/Count": 1, "Car/ME/TirePressureLR/Count": 1, "Car/ME/IsChase": true }, { "Car/ME/Number": "61", "Car/ME/TireRF/Count": 1, "Car/ME/TireRR/Count": 1, "Car/ME/TireLF/Count": 1, "Car/ME/TireLR/Count": 1, "Car/ME/IsChase": false } ], "LeaguePositions": [ { "DriverName": "James Krahula", "Number": "24", "Points": 4022, "Change": 3 }, { "DriverName": "Jeffrey Gilliam", "Number": "61", "Points": 4023, "Change": -1 }, ... ], "LeaguePositionsClass": [ "GT3": [ { "DriverName": "Jeffrey Gilliam", "Number": "61", "Points": 4023, "Change": 3 }, ... ], ... ] }
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Called when the SIMPlugin is destroyed.
|
Data |
getMaxTires()
Gets the max value for a tire.
|
Data |
getResults()
Gets the entire results structure.
|
boolean |
ProcessData(SIMPlugin SIMPlugin,
java.util.Map<java.lang.String,Data> data)
ProcessData is called from within the dedicated thread for this plug-in
every time there is data available in the queue it pops it off the queue and passes it to this method.
|
DataReady, Waiting
public Post(SIMPlugin SIMPlugin) throws SIMPlugin.SIMPluginException
SIMPlugin
- An instance of the current SIM.SIMPlugin.SIMPluginException
- If there's a problem constructing your plug-in.public void destroy()
destroy
in class SIMPluginCallback
public boolean ProcessData(SIMPlugin SIMPlugin, java.util.Map<java.lang.String,Data> data)
//When calling the SIMPlugin from this method, you must synchronize on it first. It is not thread safe. Data d; synchronized (SIMPlugin) { //do not spend much time in here, we are blocking the main thread //Get the data and get out of the synchronized block d = SIMPlugin.getData("/Session/IsGreenFlag"); d = SIMPlugin.getSession().getIsGreenFlag(); } //do something with the data
ProcessData
in class SIMPluginCallback
SIMPlugin
- A reference to the SIMPlugin instance.data
- The Data objects added to the queue.public Data getResults()
Data
container.