def setup(self): self.config = conf.conf() if not self.config.get_mapping("echo"): self.config.save_mapping("echo", "echo.yml") self.config.save_file("echo.yml", {"enabled": True}) self.config.reload() self.events = manager.manager() self.events.addCallback("dataReceived", self, self.onDataReceived, 10)
def setup(self): self.config = conf.conf() if not self.config.get_mapping("hello"): self.config.save_mapping("hello", "hello.yml") self.config.save_file("hello.yml", {"message": "Hello, world!"}) self.config.reload() self.events = manager.manager() self.events.addCallback("dataReceived", self, self.onDataReceived, 1) self.logger.info(self.config.get("hello")["message"])
def setup(self): self.config = conf.conf() self.logger = logging.getLogger("Auth") if not self.config.get_mapping("auth"): self.config.save_mapping("auth", "auth.yml") self.config.save_file("auth.yml", {"keys": {}}) self.config.reload() self.events = manager.manager() self.events.addCallback("dataReceived", self, self.onDataReceived, 99999) self.events.addCallback("protocolBuilt", self, self.onProtocolBuiltEvent, 99999) self.events.addCallback("clientDisconnected", self, self.onClientDisconnected, 0)
import logging import sys import system.config as config import system.util as util from twisted.internet import reactor from system.core import CoreFactory logging.basicConfig(format="%(asctime)s | %(name)8s | %(levelname)8s | %(message)s", datefmt="%d %b %Y - %H:%M:%S", level=(logging.DEBUG if "--debug" in sys.argv else logging.INFO)) logger = logging.getLogger("Init") logger.info("Starting up...") conf = config.conf() networking = conf.get("networking") if not networking: logger.critical("Networking configuration is unavailable. The program will now terminate.") exit(1) factory = CoreFactory() try: reactor.listenTCP(networking["port"], factory) logger.info("Now listening on port %s." % networking["port"]) reactor.run() except Exception as e: logger.error("Error starting up: %s" % e)
def setup(self): self.config = conf.conf() self.logger = logging.getLogger("Players") self.events = manager.manager() self.events.addCallback("dataReceived", self, self.onDataReceived, 0) self.events.addCallback("protocolBuilt", self, self.onProtocolBuiltEvent, 99999)