Added at_post_disconnect() hook to Player, to allow for clean deletion of players at disconnect (for example for Guest-account implementation)

This commit is contained in:
Griatch 2014-07-06 16:20:50 +02:00
parent 88efc50054
commit 1874300ad1
2 changed files with 12 additions and 0 deletions

View file

@ -383,6 +383,16 @@ class Player(TypeClass):
reason = reason and "(%s)" % reason or ""
self._send_to_connect_channel("{R%s disconnected %s{n" % (self.key, reason))
def at_post_disconnect(self):
"""
This is called after disconnection is complete. No messages
can be relayed to the player from here. After this call, the
player should not be accessed any more, making this a good
spot for deleting it (in the case of a guest player account,
for example).
"""
pass
def at_message_receive(self, message, from_obj=None):
"""
Called when any text is emitted to this

View file

@ -123,6 +123,8 @@ class ServerSession(Session):
if not self.sessionhandler.sessions_from_player(player):
# no more sessions connected to this player
player.is_connected = False
# this may be used to e.g. delete player after disconnection etc
_GA(player.typeclass, "at_post_disconnect")()
def get_player(self):
"""