https://github.com/daanv2/go-f1-library
A library to handle game packets from the F1 20xx game.
https://github.com/daanv2/go-f1-library
f1 f120xx game go golang library mit
Last synced: 8 months ago
JSON representation
A library to handle game packets from the F1 20xx game.
- Host: GitHub
- URL: https://github.com/daanv2/go-f1-library
- Owner: DaanV2
- License: mit
- Created: 2024-05-03T14:02:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-27T20:24:40.000Z (about 1 year ago)
- Last Synced: 2025-02-21T05:57:38.067Z (8 months ago)
- Topics: f1, f120xx, game, go, golang, library, mit
- Language: Go
- Homepage: https://pkg.go.dev/github.com/DaanV2/go-f1-library
- Size: 186 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go F1 Library
A library to handle game packets from the F1 20xx game.
[](https://github.com/DaanV2/go-f1-library/actions/workflows/pipeline.yaml)
# UPD example
```go
func main() {
udpAddr, err := net.ResolveUDPAddr("udp", ":21200")
if err != nil {
panic(err)
}
conn, err := net.ListenUDP("udp", udpAddr)
if err != nil {
panic(err)
}
fmt.Println("Listening on", udpAddr)results := test_util.NewResults()
parser := f1_2023.NewPacketParser()// Read from UDP listener in endless loop
go func() {
var buf [f1_2023.MAX_PACKET_SIZE]byte
for {
n, _, err := conn.ReadFromUDP(buf[0:])
if err != nil {
// Conn closed
if strings.Contains(err.Error(), "use of closed network connection"){
return
}fmt.Println(err)
} else {
results.AddPacket(parser, buf[:n])
}
}
}()// Listen for ctrl-c
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
<-cconn.Close()
}
```