pyPhotonRealtime
A pure-Python client for games running on Photon Realtime. Connect, matchmake, join rooms, raise events and track properties and players, all from Python.
Status: pre-alpha. The wire layer works (it came from prison-architect-server). The client workflow is still scaffolding. See ROADMAP.md.
Install
pip install -e ".[test,lint]" # from a checkout; not on PyPI yet
Requires Python 3.12+. Fully type-annotated (py.typed), checked with mypy --strict.
Intended usage
import time
from pyphotonrealtime import AppSettings, RealtimeClient
from pyphotonrealtime.realtime import (
ConnectionCallbacks,
MatchmakingCallbacks,
EnterRoomParams,
)
class Bot(ConnectionCallbacks, MatchmakingCallbacks):
def __init__(self, client):
self.client = client
def on_connected_to_master(self):
self.client.op_join_or_create_room(EnterRoomParams(room_name="lobby-1"))
def on_joined_room(self):
self.client.op_raise_event(1, {"hello": "world"})
client = RealtimeClient()
client.add_callback_target(Bot(client))
client.connect_using_settings(
AppSettings(app_id_realtime="<your app id>", fixed_region="eu")
)
while True:
client.service() # nothing happens on the wire without this
time.sleep(1 / 30)
Layout
| Package | Role |
|---|---|
pyphotonrealtime.protocol |
Wire format: typed parameters, packet framing, DH/AES |
pyphotonrealtime.transport |
Byte transports (TCP; UDP/WebSocket planned) |
pyphotonrealtime.peer |
PhotonPeer: one connection, the service loop, keep-alive, encryption |
pyphotonrealtime.realtime |
RealtimeClient: Name/Master/Game server workflow, rooms, players, callbacks |
Development
python -m ruff --version # must match the pin in pyproject.toml
python -m ruff check . # select = ["ALL"], see ruff.toml
python -m ruff format --check .
python -m mypy # strict
python -m pytest -q # unit tests (e2e excluded)
PHOTON_APP_ID=... python -m pytest -m e2e # live Photon Cloud, opt-in
Testing
Unit tests check that the protocol layer agrees with itself (round trips, framing).
That doesn't prove it agrees with Photon. The e2e tests in tests/e2e/ do that
against the real Photon Cloud. They need a Realtime app id in PHOTON_APP_ID, and
CI runs them nightly and on manual dispatch, never on PRs.
Metadata
Release files for pyPhotonRealtime 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyphotonrealtime-0.0.1.tar.gz | 30.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyphotonrealtime-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 78.9 kB
Release files / pyphotonrealtime-0.0.1.tar.gz
| Download URL | pyphotonrealtime-0.0.1.tar.gz |
|---|---|
| Size | 30.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29e2657c857c78257290451de52e8a6fb6e4b630658e409db4beafd55cbdf433
|
|
BLAKE2b-256 checksum How to use checksums |
e562b88105282eb7cfda730c5ce674c20bf68802693254b47927a37703bc439b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|
Release files / pyphotonrealtime-0.0.1-py3-none-any.whl
| Download URL | pyphotonrealtime-0.0.1-py3-none-any.whl |
|---|---|
| Size | 48.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b8c954cc1a534cbc15d794d617d12ee9c63a38857eba0a64cfdd7ffb886a9d8
|
|
BLAKE2b-256 checksum How to use checksums |
fbba6ddc05dcb812d7914c775d8bd041dc3530f1a8836655dec28e7ca983b2c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.5
|