OpenTTD network protocol for Python
Project description
openttd-protocol
This library implements the OpenTTD network protocol. It mostly is meant to be used for OpenTTD's backend services, like BaNaNaS server and master server.
Usage
pip install openttd-protocol
Now in your Python code you can import the protocol. Example:
import asyncio
import logging
from openttd_protocol.protocol.coordinator import CoordinatorProtocol
log = logging.getLogger(__name__)
class Application:
async def receive_PACKET_COORDINATOR_CLIENT_REGISTER(self, source, protocol_version, game_type, server_port):
# Your logic goes here
pass
def main():
application = Application()
loop = asyncio.get_event_loop()
server = loop.run_until_complete(loop.create_server(lambda: CoordinatorProtocol(application), host="127.0.0.1", port=12345, reuse_port=True, start_serving=True))
try:
loop.run_until_complete(server.serve_forever())
except KeyboardInterrupt:
pass
log.info("Shutting down game_coordinator ...")
server.close()
if __name__ == "__main__":
main()
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 openttd-protocol-1.7.1.tar.gz.
File metadata
- Download URL: openttd-protocol-1.7.1.tar.gz
- Upload date:
- Size: 24.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be1a6f046bc3e493527ffe6594088114d8dcd424116a9738d815229e411f684d
|
|
| MD5 |
e885da928e5d6e1bd4ee96a66a64feab
|
|
| BLAKE2b-256 |
a266444e1c48f023301d20c78cdea69522800ed1545419fd0ca86e316a9a3601
|
File details
Details for the file openttd_protocol-1.7.1-py3-none-any.whl.
File metadata
- Download URL: openttd_protocol-1.7.1-py3-none-any.whl
- Upload date:
- Size: 29.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23cd696edc8952303d20f2a81c2680ae17f442499fb946882b004eefdcbafd9b
|
|
| MD5 |
9d26ad51e582b36344f577139d85654b
|
|
| BLAKE2b-256 |
8f24f00cebfd2eac7ed7fe99d91f9530b063825f4586232db6663d3e4159471a
|