Event-Driven API for rFactor 2 servers

A small patch with high impact.

Event-Driven API for rFactor 2 servers

I am currently working on the Hook patch (https://github.com/apx-simracing/issues/issues/29) of APX. This patch will add support for an event based hook system.

Hooks?

Basically, you can now add your own code which will be executed at certain events, e. g. if a car connects to the server. This feature allows implementation of following ideas:

  • Remove duplicate penalties on a car if a car recieves penalties
  • Do yellow-flag checks (e. g. for non-allowed overtakes)
  • Get a proper race event log
  • Identify stationary/ limping cars
  • Identify driver swaps
  • Write discord messages for happening events

With usage of hooks, the infrastructure can react to in-server events directly and has now need to do a permanent listening on the server status endpoint. This reduces load and makes the connection more efficient.

Supported events

  • onCarCountChange
  • onDriverPenaltyChange
  • onSessionChange
  • onFinishStatusChange    
  • onPitStateChange  
  • onLowSpeed
  • onShownFlagChange    
  • onStart    
  • onStop  
  • onDriverSwap

All of these additions are done without a dependency on the server. There is no need for a plugin, just a reciever instance must be running besides the server.

Documentation and examples

I added the new repository https://github.com/apx-simracing/hooks to include a few examples for hooks, a base documentation is written down on https://wiki.apx.chmr.eu/doku.php?id=hooks

More infos on the project can be seen on https://apx.chmr.eu


Photo by Mel Baylon on Unsplash