An XML RPC client for Trackmania Nations Forever dedicated servers.
Project description
TrackMania Nations Forever Client
This Python client is intended to be used with the TM Nations Forever remote procedure endpoint.
The available methods are documented at ListMethods.
It has been built for the dedicated server version of 2011-02-21.
The hardcoded TrackMania RPC method calls have been AI generated and mostly not tested!
Usage Example
from trackmania_client import TrackManiaClient as TMClient
import asyncio
async def main():
HOST = 'localhost'
PORT = 5000
async with TMClient(HOST, PORT) as client:
print('Connected!')
await client.authenticate('SuperAdmin', 'SuperAdmin')
print('Authenticated!')
version = await client.get_version()
print(f'Version: {version}')
status = await client.get_status()
print(f'Status: {status}')
player_list = await client.get_player_list(100, 0)
print(f'Players: {player_list}')
if __name__ == '__main__':
asyncio.run(main())
If no response is received after the default timeout of 10 seconds a TimeoutError is raised.
Callback Usage
from trackmania_client import TrackManiaClient as TMClient
import asyncio
def callback_handler(callback: str, data: tuple):
print(f'Callback: {callback}, {data}')
async def main():
HOST = 'localhost'
PORT = 5000
async with TMClient(HOST, PORT) as client:
print('Connected!')
await client.authenticate('SuperAdmin', 'SuperAdmin')
print('Authenticated!')
client.register_general_callback_handler(callback_handler)
result = await client.enable_callbacks()
print(f'Callbacks enabled: {result}')
echo = await client.echo()
print(f'Echo: {echo}')
client.unregister_general_callback_handler(callback_handler)
result = await client.disable_callbacks()
print(f'Callbacks disabled: {result}')
echo = await client.echo()
if __name__ == '__main__':
asyncio.run(main())
Output:
Connected!
Authenticated!
Callbacks enabled: True
Callback: TrackMania.Echo, echo param 2
Echo: True
Callbacks disabled: True
Handlers can also be registered to specific callbacks:
from trackmania_client import TrackManiaCallback as TMCallback
client.register_callback_handler(TMCallback.ECHO, echo_callback_handler)
client.unregister_callback_handler(TMCallback.ECHO, echo_callback_handler)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trackmania-nations-forever-client-0.1.1.tar.gz.
File metadata
- Download URL: trackmania-nations-forever-client-0.1.1.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
573ffcae995b6e60d681c4b08fc0fe696c20f5a15c9edd5f7e70479ab1b8935a
|
|
| MD5 |
e5760af74172bf2972b7e81bb4f9ea54
|
|
| BLAKE2b-256 |
e8f8dd759c131a70e3fc2b4f6c5580748fb9dbdc1c7bb2003d58d7ec316ba5ac
|
File details
Details for the file trackmania_nations_forever_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: trackmania_nations_forever_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ba45abbbd2ef3fa55d382cc0317e83431d269ce62a01b1c3cb7633a729b13b6
|
|
| MD5 |
13b1b6175517144dc82797d5648fc196
|
|
| BLAKE2b-256 |
39777be4ebcc5c9cd81c7e5678337aa501be3d3d3a1971caf7f020d875a581c1
|