[!] Fix events

[~] Minor updates
This commit is contained in:
SantaSpeen committed 2024-07-27 05:04:49 +03:00
1 parent bf1c6d2c41
commit 9e86c41a6a
5 files changed
+12 -17

No files matched your search

+1 -2
View File
@@ -133,10 +133,9 @@ class Client:
await self._send(f"C:{message}", to_all=to_all) await self._send(f"C:{message}", to_all=to_all)
async def send_event(self, event_name, event_data, to_all=True): async def send_event(self, event_name, event_data, to_all=True):
self.log.debug(f"send_event: {event_name}:{event_data}; {to_all=}")
if isinstance(event_data, (list, tuple, dict)): if isinstance(event_data, (list, tuple, dict)):
event_data = json.dumps(event_data, separators=(',', ':')) event_data = json.dumps(event_data, separators=(',', ':'))
else:
event_data = f"{event_data!r}"
if len(event_data) > 104857599: if len(event_data) > 104857599:
self.log.error("Client data too big! >=104857599") self.log.error("Client data too big! >=104857599")
return return
+1 -1
View File
@@ -10,7 +10,7 @@ __title__ = 'KuiToi-Server'
__description__ = 'BeamingDrive Multiplayer server compatible with BeamMP clients.' __description__ = 'BeamingDrive Multiplayer server compatible with BeamMP clients.'
__url__ = 'https://github.com/kuitoi/kuitoi-Server' __url__ = 'https://github.com/kuitoi/kuitoi-Server'
__version__ = '0.4.8 (pre)' __version__ = '0.4.8 (pre)'
__build__ = 2474 # Я это считаю лог файлами __build__ = 2483 # Я это считаю лог файлами
__author__ = 'SantaSpeen' __author__ = 'SantaSpeen'
__author_email__ = 'admin@kuitoi.su' __author_email__ = 'admin@kuitoi.su'
__license__ = "FPA" __license__ = "FPA"
+1 -1
View File
@@ -315,7 +315,7 @@ class Core:
await ev.call_async_event("onServerStopped") await ev.call_async_event("onServerStopped")
await self.__gracefully_kick() await self.__gracefully_kick()
if config.Options['use_lua']: if config.Options['use_lua']:
ev.call_event("_lua_plugins_unload") await ev.call_async_event("_lua_plugins_unload")
await ev.call_async_event("_plugins_unload") await ev.call_async_event("_plugins_unload")
self.run = False self.run = False
total_time = time.monotonic() - self.start_time total_time = time.monotonic() - self.start_time
+2 -3
View File
@@ -23,13 +23,12 @@ class KuiToi:
_plugins_dir = "" _plugins_dir = ""
def __init__(self, name): def __init__(self, name):
if name is None: if not name:
raise AttributeError("KuiToi: Name is required") raise AttributeError("KuiToi: Name is required")
self.__log = get_logger(f"Plugin | {name}") self.__log = get_logger(f"Plugin | {name}")
self.__name = name self.__name = name
self.__dir = Path(self._plugins_dir) / self.__name self.__dir = Path(self._plugins_dir) / self.__name
if not self.__dir.exists(): os.makedirs(self.__dir, exist_ok=True)
os.mkdir(self.__dir)
@property @property
def log(self): def log(self):
@@ -608,14 +608,6 @@ class LuaPluginsLoader:
"ImScaredOfUpdates": False, "ImScaredOfUpdates": False,
"SendErrorsShowMessage": False, "SendErrorsShowMessage": False,
"SendErrors": False "SendErrors": False
},
"HTTP": {
"HTTPServerIP": config.WebAPI['server_ip'],
"HTTPServerPort": config.WebAPI['server_port'],
"SSLKeyPath": None,
"SSLCertPath": None,
"UseSSL": False,
"HTTPServerEnabled": config.WebAPI['enabled'],
} }
} }
with open("ServerConfig.toml", "w") as f: with open("ServerConfig.toml", "w") as f:
@@ -671,10 +663,15 @@ class LuaPluginsLoader:
self.log.error(f"Exception onInit from `{name}`: {e}") self.log.error(f"Exception onInit from `{name}`: {e}")
self.log.exception(e) self.log.exception(e)
def unload(self, _): async def unload(self, _):
self.log.debug("Unloading lua plugins") self.log.debug("Unloading lua plugins")
for name, data in self.lua_plugins.items(): for name, data in self.lua_plugins.items():
if data['ok']: if data['ok']:
self.log.info(i18n.plugins_lua_unload.format(name)) self.log.info(i18n.plugins_lua_unload.format(name))
for _, timer in data['lua'].globals().MP._event_timers.items(): MP = data['lua'].globals().MP
self.log.debug("gather")
await asyncio.gather(*MP.tasks)
self.log.debug("timers")
for _, timer in MP._event_timers.items():
timer.stop() timer.stop()
self.log.debug("unloaded")