Implement AbortHandlerChain exception for aborting future handlers

This commit is contained in:
Ben 2020-07-01 00:11:39 +01:00
parent bc059bacb8
commit f4d4044a04
2 changed files with 7 additions and 1 deletions

View File

@ -13,6 +13,10 @@ class AuthorityError(Exception):
"""Raised when a packet is received but user has not yet authenticated""" """Raised when a packet is received but user has not yet authenticated"""
class AbortHandlerChain(Exception):
"""Exception raised when handler wants to abort the rest of the handler chain"""
class _Packet: class _Packet:
__slots__ = ['id'] __slots__ = ['id']

View File

@ -4,7 +4,7 @@ from xml.etree.cElementTree import Element, SubElement, tostring
import defusedxml.cElementTree as Et import defusedxml.cElementTree as Et
from houdini.constants import ClientType from houdini.constants import ClientType
from houdini.handlers import AuthorityError, XMLPacket, XTPacket from houdini.handlers import AuthorityError, AbortHandlerChain, XMLPacket, XTPacket
class Spheniscidae: class Spheniscidae:
@ -161,6 +161,8 @@ class Spheniscidae:
await self.__handle_xt_data(data) await self.__handle_xt_data(data)
except AuthorityError: except AuthorityError:
self.logger.debug(f'{self} tried to send game packet before authentication') self.logger.debug(f'{self} tried to send game packet before authentication')
except AbortHandlerChain as e:
self.logger.info(f'Handler chain aborted: {str(e)}')
async def run(self): async def run(self):
await self._client_connected() await self._client_connected()