Client and sessions¶
A Client opens maps as sessions. A Session is one map, loaded and ready; each Session.connect()
opens a Gym on it. Both are context managers: a session closes itself, and every gym on it, at the end of its
block.
from tickgym import Client, TelemetryGroup
with Client().open_map(r"C:\Maps\Example.Map.Gbx") as session:
with session.connect(TelemetryGroup.RACE | TelemetryGroup.VEHICLE) as gym:
...
- class Client(origin: str = 'http://127.0.0.1:46321', timeout: float = 120.0)¶
TICK on a machine, which opens maps as sessions.
- Parameters:
origin – TICK’s address. The default is TICK on this machine.
timeout – Seconds to wait on TICK before giving up.
- open_map( ) Session¶
Opens a session on a map file of this machine. The first session on a map loads its world, which takes a few seconds; later sessions on the same map open at once.
- Parameters:
path – The
.Map.Gbxfile.laps – Laps to race on a multilap map; the map’s own count when
None.
- Returns:
The session, ready for
Session.connect.- Raises:
TickError – TICK refused, for example because the file is not a map it can load.
- open_map_bytes(data: bytes, laps: int | None = None) Session¶
Opens a session on a map given as bytes, for a map that is not a file on this machine.
- Parameters:
data – The contents of a
.Map.Gbxfile.laps – Laps to race on a multilap map; the map’s own count when
None.
- Raises:
TickError – TICK refused the map.
- sessions() list[SessionSummary]¶
Every session open on the host.
- session(session_id: int) SessionDetail¶
One session and its open gyms.
- Raises:
TickError – No session has that id.
- status() HostStatus¶
TICK’s capacity and state.
- class Session¶
One map, loaded and ready on the server. Each
connect()opens a gym on it, alive for as long as its connection; the session itself stays untilclose(), or until it has had no connection for the host’s idle timeout. A session is a context manager that closes itself.- info: SessionInfo¶
The session as it was opened.
- connect(
- telemetry: TelemetryGroup,
- lidar: Lidar | None = None,
- timeout: float | None = 60.0,
Opens a gym on this map over its own connection.
- Parameters:
telemetry – The groups every sample carries, combined with
|.lidar – The rays to cast on every sample.
TelemetryGroup.LIDARis its scan, and is in the telemetry exactly when a lidar is given.timeout – Seconds to wait on the server before giving up, for connecting and for every read and write;
Nonewaits forever.
- Returns:
The gym, a context manager that closes itself.
- Raises:
CapacityError – The host has no gym slot free.
SchemaMismatchError – This package was built for a different server version.
- gyms() tuple[GymSummary, ...]¶
The gyms open on this session now.
Records¶
- class SessionInfo¶
A session as it was opened.
- map: MapSummary¶
The map it is on.
- class SessionSummary¶
A session as
Client.sessionslists it.- map: MapSummary¶
The map it is on.
- class SessionDetail¶
A session and its open gyms, as
Client.sessionreturns it.
- class GymSummary¶
One open gym of a session, as
Session.gymslists it.- telemetry: TelemetryGroup¶
The groups it samples, combined with
|.
- class MapSummary¶
A map as the server identifies it.
- vehicle: VehicleType¶
The car the map starts in.
- class Endpoint¶
Where a session’s gym socket listens.
- class HostStatus¶
TICK’s state, as
Client.statusreturns it.- resources: GameResourcePaths | None¶
The game folders in use, or
Noneuntil TICK has reported them.