Move background task calls to their respective handler modules

This commit is contained in:
Ben 2020-06-12 15:17:12 +01:00
parent 2ef0f457db
commit d25df447cc
4 changed files with 13 additions and 11 deletions

View File

@ -157,6 +157,11 @@ def determine_song_length(track_pattern):
return int(track_length, 16) // 1000
@handlers.boot
async def music_service_start(server):
server.music = SoundStudio(server)
@handlers.handler(XTPacket('musictrack', 'broadcastingmusictracks'), client=ClientType.Vanilla)
@handlers.player_in_room(SoundStudio.StudioRoomId)
async def handle_broadcasting_tracks(p):

View File

@ -231,6 +231,8 @@ async def puffles_load(server):
server.puffle_furniture_treasure = await PuffleTreasureFurniture.query.gino.all()
server.puffle_clothing_treasure = await PuffleTreasureItem.query.gino.all()
server.puffle_killer = asyncio.create_task(decrease_stats(server))
@handlers.handler(XMLPacket('login'), priority=Priority.Low)
@handlers.allow_once

View File

@ -68,6 +68,12 @@ async def server_egg_timer(server):
await p.send_error_and_disconnect(910)
@handlers.boot
async def heartbeat_service_start(server):
server.heartbeat = asyncio.create_task(server_heartbeat(server))
server.egg_timer = asyncio.create_task(server_egg_timer(server))
MemberWarningDaysToExpiry = 14
MemberWarningPostcardsVanilla = [122, 123]
MemberWarningPostcardsLegacy = [163]

View File

@ -26,11 +26,6 @@ from houdini.handlers import XTListenerManager, XMLListenerManager, DummyEventLi
from houdini.plugins import PluginManager
from houdini.commands import CommandManager
from houdini.handlers.play.player import server_heartbeat, server_egg_timer
from houdini.handlers.play.pet import decrease_stats
from houdini.handlers.play.music import SoundStudio
class Houdini:
@ -178,12 +173,6 @@ class Houdini:
await self.plugins.setup(houdini.plugins)
self.heartbeat = asyncio.create_task(server_heartbeat(self))
self.egg_timer = asyncio.create_task(server_egg_timer(self))
self.puffle_killer = asyncio.create_task(decrease_stats(self))
self.music = SoundStudio(self)
async with self.server:
await self.server.serve_forever()