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
openttd-protocol-0.1.1.tar.gz
(22.0 kB
view hashes)
Built Distribution
Close
Hashes for openttd_protocol-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b2e66cbfc69ee0edbff4c3d9766522e28b0d3a7b767832b4a7b3b6f98901113 |
|
MD5 | d979421cd239b2f3f54cbfa1e796a4ab |
|
BLAKE2b-256 | d7de8e1bac7d26a6e8322d566073c47bcacd00346702269580bc6b3e287f2667 |