sampy/sampy/env.py
2020-03-29 19:12:31 +02:00

21 lines
549 B
Python

import asyncio
from threading import Thread
from .struct.server import ServerConfig
from .server import Server
class Environment(Thread):
def __init__(self, config: ServerConfig):
super().__init__()
self.daemon = True
self.event_loop = asyncio.get_event_loop()
self.config = config
self.server = Server(self.config)
def command(self, cmd: str):
self.event_loop.create_task(self.server.on_command(cmd))
def run(self):
self.event_loop.run_until_complete(self.server.main())