-
Notifications
You must be signed in to change notification settings - Fork 55
Event System
Pedro Faria edited this page Jun 17, 2024
·
15 revisions
If enabled, make a POST
HTTP request to the configured urls when the configured events happend.
Available events:
- "instance_started"
- "instance_stopped"
- "instance_live_new_driver"
- "instance_live_remove_connection"
- "instance_live_new_lap"
- "instance_live_session_phase_changed"
- "instance_live_new_damage_zone"
- "instance_live_reseting_race_weekend"
- "instance_live_session_changed"
callback:
enabled: false
clients:
# simple example (enabled, no http headers and all events)
- url: "http://localhost:3000/callback"
# complete example (enabled, with custom headers and few events)
- url: "http://localhost:3001/callback"
enabled: true
headers:
"some-header": "aabbcc"
events:
- "instance_started"
- "instance_stopped"
# disabled client
- url: "http://localhost:3003/callback3"
enabled: false
Dedicated Server has been started
{
"eventName": "instance_started",
"timestamp": "2024-06-06T16:08:03.056223682Z",
"instanceId": "1714097074",
"instanceName": "Server name (by accweb)",
"track": "barcelona",
"udpPort": 9600,
"tcpPort": 9600,
"nrDrivers": 0
}
{
"eventName": "instance_stopped",
"timestamp": "2024-06-06T16:08:03.056223682Z",
"instanceId": "1714097074",
"instanceName": "Server name (by accweb)",
"track": "barcelona",
"udpPort": 9600,
"tcpPort": 9600,
"nrDrivers": 0
}
{
"eventName": "instance_live_new_driver",
"timestamp": "2024-06-06T16:07:46.077205887Z",
"instanceId": "1714097074",
"instanceName": "Server name (by accweb)",
"track": "spa",
"udpPort": 9600,
"tcpPort": 9600,
"nrDrivers": 5,
"data": {
"playerName": "m suneo",
"playerID": "S99999999999999999",
"carID": 1005,
"raceNumber": 82,
"carModel": 30
}
}
{
"eventName": "instance_live_remove_connection",
"timestamp": "2024-06-06T15:43:52.128381051Z",
"instanceId": "1714097074",
"instanceName": "Server name (by accweb)",
"track": "spa",
"udpPort": 9600,
"tcpPort": 9600,
"nrDrivers": 5,
"data": {
"playerName": "m suneo",
"playerID": "S99999999999999999"
}
}
{
"eventName": "instance_live_new_lap",
"timestamp": "2024-06-06T15:43:53.838493715Z",
"instanceId": "1714097074",
"instanceName": "Server name (by accweb)",
"track": "spa",
"udpPort": 9600,
"tcpPort": 9600,
"nrDrivers": 4,
"data": {
"playerName": "fox suckfoxwaifu",
"playerID": "S99999999999999999",
"carID": 1003,
"raceNumber": 69,
"carModel": 24,
"lapTimeMS": 142665,
"timestampMS": 72956232,
"flags": 0,
"fuel": 20,
"s1": "0:41:567",
"s2": "1:03:557",
"s3": "0:37:540",
"hasCut": false,
"inLap": false,
"outLap": false,
"sessionOver": false
}
}
{
"eventName": "instance_live_session_phase_changed",
"timestamp": "2024-06-06T16:07:58.865758625Z",
"instanceId": "1714097074",
"instanceName": "Server name (by accweb)",
"track": "spa",
"udpPort": 9600,
"tcpPort": 9600,
"nrDrivers": 5,
"data": {
"session": "Race",
"phase": "session",
"remaining": 20
}
}
{
"eventName": "instance_live_new_damage_zone",
"timestamp": "2024-06-06T15:44:45.008711783Z",
"instanceId": "1714097074",
"instanceName": "Server name (by accweb)",
"track": "spa",
"udpPort": 9600,
"tcpPort": 9600,
"nrDrivers": 4,
"data": {
"playerName": "Mika azantzinen",
"playerID": "S99999999999999999",
"carID": 1008,
"raceNumber": 888,
"carModel": 24
}
}
{
"eventName": "instance_live_reseting_race_weekend",
"timestamp": "2024-06-07T19:24:28.292786973Z",
"instanceId": "1714097074",
"instanceName": "Server name (by accweb)",
"track": "spa",
"udpPort": 9600,
"tcpPort": 9600,
"nrDrivers": 5,
"data": {
"live": {
"1001": {
"raceNumber": 999,
"carModel": 22,
"drivers": [
{
"playerName": "Joe Siffert",
"playerID": "S99999999999999999"
}
],
"currentDriver": {
"playerName": "Joe Siffert",
"playerID": "S99999999999999999"
},
"fuel": 11,
"position": 3,
"nrLaps": 9,
"bestLapMS": 141967,
"lastLapMS": 194437,
"lastLapTimestampMS": 73720723,
"laps": [
{
"driverIndex": 0,
"lapTimeMS": 603557,
"timestampMS": 72526299,
"flags": 0,
"s1": "8:22:442",
"s1MS": 502442,
"s2": "1:03:225",
"s2MS": 63225,
"s3": "0:37:890",
"s3MS": 37890,
"fuel": 43,
"hasCut": false,
"inLap": false,
"outLap": false,
"sessionOver": false
}
],
"currLap": {
"driverIndex": 0,
"lapTimeMS": 2147483647,
"timestampMS": 73720723,
"flags": 0,
"s1": "1:32:475",
"s1MS": 92475,
"s2": "1:03:940",
"s2MS": 63940,
"s3": "0:38:022",
"s3MS": 38022,
"fuel": 0,
"hasCut": false,
"inLap": false,
"outLap": false,
"sessionOver": false
}
}
}
}
}
{
"eventName": "instance_live_session_changed",
"timestamp": "2024-06-07T19:24:28.292786973Z",
"instanceId": "1714097074",
"instanceName": "Server name (by accweb)",
"track": "spa",
"udpPort": 9600,
"tcpPort": 9600,
"nrDrivers": 5,
"data": {
"oldSession": "Qualifying",
"session": "Race",
"live": {
"1001": {
"raceNumber": 999,
"carModel": 22,
"drivers": [
{
"playerName": "Joe Siffert",
"playerID": "S99999999999999999"
}
],
"currentDriver": {
"playerName": "Joe Siffert",
"playerID": "S99999999999999999"
},
"fuel": 11,
"position": 3,
"nrLaps": 9,
"bestLapMS": 141967,
"lastLapMS": 194437,
"lastLapTimestampMS": 73720723,
"laps": [
{
"driverIndex": 0,
"lapTimeMS": 603557,
"timestampMS": 72526299,
"flags": 0,
"s1": "8:22:442",
"s1MS": 502442,
"s2": "1:03:225",
"s2MS": 63225,
"s3": "0:37:890",
"s3MS": 37890,
"fuel": 43,
"hasCut": false,
"inLap": false,
"outLap": false,
"sessionOver": false
}
],
"currLap": {
"driverIndex": 0,
"lapTimeMS": 2147483647,
"timestampMS": 73720723,
"flags": 0,
"s1": "1:32:475",
"s1MS": 92475,
"s2": "1:03:940",
"s2MS": 63940,
"s3": "0:38:022",
"s3MS": 38022,
"fuel": 0,
"hasCut": false,
"inLap": false,
"outLap": false,
"sessionOver": false
}
}
}
}
}
Very simple application in golang to receive the callback request and print the payload.
package main
import (
"fmt"
"io"
"log"
"net/http"
"os"
)
func handlePost(w http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodPost {
w.WriteHeader(http.StatusBadRequest)
}
defer req.Body.Close()
buf, _ := io.ReadAll(req.Body)
fmt.Printf("%s\n", string(buf))
w.WriteHeader(http.StatusOK)
}
func main() {
host := os.Args[1]
http.HandleFunc("/callback", handlePost)
log.Fatal(http.ListenAndServe(host, nil))
}