[](https://travis-ci.org/joaoubaldo/acudpclient)
ACUDPClient is a Python module that can be used to communicate with an Assetto Corsa dedicated server.
Using its UDP protocol, real time telemetry, lap timings and session information is pushed to the client.
A few actions, like sending/broadcasting messages are also available.
## Installation
```bash
$ python setup.py install
```
or
```bash
$ pip install acudpclient
```
(virtualenv is recommended)
## Testing
```bash
$ nosetests
```
### Capturing real data for testing purposes
1. Start the ACServer with UDP active.
2. Capture the data using `tcpdump`:
```bash
$ tcpdump -w /tmp/ac_out.pcap -s0 -i lo -n udp dst port 10000
```
3. Extract all udp payload from the pcap file:
```bash
$ tshark -r /tmp/ac_out.pcap -T fields -e data | tr -d '\n' | perl -pe 's/([0-9a-f]{2})/chr hex $1/gie' > /tmp/ac_out
```
4. `/tmp/ac_out` contains binary data sent by ACServer.
## Usage
The client should be initialized like this:
```python
from acudpclient.client import ACUDPClient
client = ACUDPClient(port=10000, remote_port=10001, host='127.0.0.1')
client.listen()
```
* `remote_port` and `host` are used to send data to the AC server
* `listen()` will bind the server socket to `port`.
Server events can be handled directly or by event subscribers. In
both cases, `get_next_event()` method must be invoked in the
application's main loop.
When handling events directly, a call to `get_next_event()`
might return `None`, meaning there's no event available at that
point (the internal `ACUDPClient` socket is non-blocking).
When creating a subscriber class, specific events can be handled by creating
methods with the following naming scheme `on_<event_type>(self, event)`
where `event_type` is any of the types found in
`acudpclient.protocol.ACUDPConst` class (see Usage).
Events passed to `on_<event_type>(self, event)` are dictionaries containing
different keys depending on the event's type. Refer to `acudpclient.client import ACUDPClient`
to see which keys are available per event type.
## Examples
Handle events directly:
```python
from acudpclient.client import ACUDPClient
client = ACUDPClient(port=10000, remote_port=10001)
client.listen()
client.get_session_info()
while True:
event = client.get_next_event(call_subscribers=False)
print event
```
Handle events with a subscriber:
```python
from acudpclient.client import ACUDPClient
class ACEventHandler(object):
def on_ACSP_LAP_COMPLETED(self, event):
print event
def on_ACSP_NEW_SESSION(self, event):
print event
def on_ACSP_NEW_CONNECTION(self, event):
print event
handler = ACEventHandler()
client = ACUDPClient(port=10000, remote_port=10001)
client.listen()
client.subscribe(handler)
while True:
client.get_next_event()
```
Metadata
Release files for acudpclient 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| acudpclient-1.1.0.tar.gz | 9.0 kB | Without provenance | Details for acudpclient-1.1.0.tar.gz |
Release files / acudpclient-1.1.0.tar.gz
| Download URL | acudpclient-1.1.0.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e51cedf13685f1c5d2dc86b0800be7716215c339c4d55ec74ebbd40f92d1a47
|
|
BLAKE2b-256 checksum How to use checksums |
aef3ec5ba444dc10eb6a6851c6a0e9bfb215985ec6f99938b3effb887b41da69
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for acudpclient 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.