21 lines
549 B
Python
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())
|